Coder Social home page Coder Social logo

open-xml-templating / docxtemplater Goto Github PK

View Code? Open in Web Editor NEW
2.9K 2.9K 339.0 26.66 MB

Generate docx, pptx, and xlsx from templates (Word, Powerpoint and Excel documents), from Node.js or the browser. Demo: https://www.docxtemplater.com/demo. #docx #office #generator #templating #report #json #generate #generation #template #create #pptx #docx #xlsx #react #vuejs #angularjs #browser #typescript #image #html #table #chart

Home Page: https://www.docxtemplater.com

License: Other

HTML 0.14% JavaScript 97.58% Shell 1.44% TypeScript 0.85%
docx docx-generation docx-generator docx-template excel javascript microsoft office powerpoint pptx template word xlsx

docxtemplater's People

Contributors

aarbel avatar aaronbaker avatar aymericbouzy avatar balazsbohonyi avatar benasher44 avatar bilal-elchami avatar cabbiepete avatar carolineconchon avatar cheapsteak avatar codingwatchcollector avatar dderg avatar edi9999 avatar extend1994 avatar fponticelli avatar frapontillo avatar harish-aka-shivi avatar kohakade avatar marti4ka avatar maxrcd avatar netei avatar nrekretep avatar oleksandr-danylchenko avatar p0rt3rh avatar paultopia avatar sgrignard avatar shadab14meb346 avatar sujith3g avatar tamagokun avatar tdonia avatar totalwar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docxtemplater's Issues

nested JSON objects

Great app! I have a need to be able to nested-object properties in my template. For example, I have a tag object that may look like this:

{
    "name": "Tom",
    "address" : 
         {"state": "TX", 
          "city": "Austin"}
 }

In my Word template I'd like to be able to use the following angular-like syntax:

{address.city}

I tried it with the latest version from npm and it didn't appear to work - is this a feature that may be added in the future?

Table Loop not working

I can't get this to work correctly, even the demo doesn't work properly (it just puts all of the content in one row).

Cant do anything

I want to do a simple cv constructor. I have a code. What i must to do with that issue. I cant do anything. So many examples i tryed, but nothing. What i need: to get the values from fields and than put it to the my file. I cant change nothing.
123
Here is a code:

<script language="javascript">
    /*<![CDATA[*/
        function load(){
            alert("JS on!");
        }
    /*]]>*/
</script>

Main information :

    <form>

        First name*  <input type="text" id="firstName" name="constructor"><br>

        Last name*  <input type="text" id="lastName" name="constructor"><br>

        Third name* <input type="text" id="thirdName" name="constructor"><br>

        Address* <input type="text" id="address" name="constructor"><br>

        Birthday*  <input type="text" id="birthday" name="constructor"><br>
        Email*  <input type="text" id="email" name="constructor"><br>
        Phone number*  <input type="text" id="phoneNumber" name="constructor"><br>
        Web-site  <input type="text" id="website" name="constructor"><br>
    </form>
    Goal* 
    <form>
        <textarea rows="10" cols="50" maxlength="500" id="goal" name="constructor"></textarea>
    </form>
    About yourself* 
    <form>
        <textarea rows="10" cols="50" maxlength="500" id="aboutYS" name="constructor"></textarea>
    </form>
    Education* 
    <form>
        <textarea rows="10" cols="50" maxlength="500" id="education" name="constructor"></textarea>
    </form>
    Skills* 
    <form>
        <textarea rows="10" cols="50" maxlength="500" id="skills" name="constructor"></textarea>
    </form>
    Languages* 
    <form>
        <textarea rows="10" cols="50" maxlength="500" id="languages" name="constructor"></textarea>
    </form>
    Professional experience(if u have) :
    <form>
        Company <input type="text" id="company" name="constructor"><br>
        About company <input type="text" id="aboutCO" name="constructor"><br>
        Post <input type="text" id="post" name="constructor"><br>
        Web-site <input type="text" id="websiteCO" name="constructor"><br>
        Date <br>
        <input type="checkbox" id="isWork"> I am working here right now <br>
        Description <br>


        <textarea rows="10" cols="50" maxlength="500" id="description" name="constructor"></textarea>
    </form>
    <form>
        <input type="button" id="execute" onClick="constrCV();" value="Construct">
    </form>
    <h1 id="footer"></h1>

Please help. Thanks.

Cyrillic characters coding problem

I've tried to use library to generate reports.
But I need to make reports in Russion for our clients.
So if I tried tags like these:

{
    'fields.director': "Пупкина В.И.",
}

It looks within document like this:

��пкина �.�.

It's coding problem.

npm installer assumes root user or non-root -g

Hi!

Just tried to install docxtemplater like this:

lr-pc:docx-report lr$ sudo npm -g install docxtemplater
npm http GET https://registry.npmjs.org/docxtemplater
npm http 200 https://registry.npmjs.org/docxtemplater
npm http GET https://registry.npmjs.org/docxtemplater/-/docxtemplater-0.5.2.tgz
npm http 200 https://registry.npmjs.org/docxtemplater/-/docxtemplater-0.5.2.tgz

> [email protected] preinstall /usr/local/lib/node_modules/docxtemplater
> npm install -g jasmine-node && npm install -g browserify

As you can see, it tries to execute npm install -g without root rights.
This is Ok in some cases, but sadly most people don't own /usr/local/lib/node_modules, because that is how node installer works by default.

Not sure where it happens, because you don't seem to have this preinstall in your package.json, but anyway it seems to be kind of little annoyance.

Interesting, this thing happens even if user owns /usr/local/lib/node_modules, but runs npm from sudo.

Array.prototype.max Bug

 Array.prototype.max = function() {
    return Math.max.apply(null, this);
  };

  Array.prototype.min = function() {
    return Math.min.apply(null, this);
  };

global change , this will made my iterator crash

conditional statements

I looked briefly through the angular parsing and it looks like are ways to do conditional testing in templates, but don't see any demos. Is there an easy way to implement something like:

{#if foo == bar} I show up only if foo equals bar {/if}

The above being more like Handlebars.

Something like {{ foo == bar | "I am showing up here" }} may also work for my needs, but ultimately I need to show / hide certain sections of a document template based on the input.

Doesn't work with utf-8 symbols in template

If docx template file contains non-latin characters (for example cyrillic characters), they are converted into wrong symbols (something as "��ове�ка"). This happens because of incorrect encoding/decoding in base64. How is it possible to fix it?
Text in variables inserted correctly.

html canvas and checkbox

Hi,
I have some questions, does docxtemplater support checkbox?
an other question it can be possible to pass canvas image (toDataURL) to a word document?
if so, how can i do this ?

Thanks

type options for jszip.generate

Hello,
i'am new to nodejs and i'am using docxtemplater on nodejs server.
I whant to pass to client docx file.
here's my working sample -

var doc = doc.output({type:{base64:false}});
res.setHeader('Content-Type', 'application/vnd.openxmlformats');
res.setHeader("Content-Disposition", "attachment; filename=" + "avanc.docx");
res.status(200).end(doc, 'binary');

I've figured that if I put these changes into docxgen.js line 932
result = this.zip.generate(options.type)
, this work quite well, user gets the docx.

Maybe you can put these changes in your code, so we can pass options directly to jszip.generate.

Support for non-png QR-code images

Hello!

What do you think about supporting non-png images (such as gif and jpg)?
I am unsure if it is very useful feature (I don't think you want docxtemplater to become full-featured giant bloatware), but definetly something to consider.

Anyway, I think it is good idea to put clear and explicit description of format limitations in documentation (i.e., explicitly state in demos and docs that currently it works only with PNG). Now this restriction is unclear unless you look at the source code and see pngjs there.

Callback for output method

Could you please add callback for output method because fs.writeFile is async.

output = function(download, name, callback) {
                        var result;
                        if (download == null) {
                            download = true;
                        }
                        if (name == null) {
                            name = "output.docx";
                        }

                        this.calcZip();
                        result = this.zip.generate();
                        if (download) {
                            if (env === 'node') {
                                fs.writeFile(process.cwd() + '/' + name, result, 'base64', function(err) {
                                    if (err) {
                                        throw err;
                                    }
                                    if (callback) {
                                        callback();
                                    }
                                    return console.log('file Saved');
                                });
                            } else {
                                document.location.href = "data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," + result;
                            }
                        }
                        return result;
                    };

Embed XML , use table

@edi9999 , HI

{complexXml:'<w:p><w:pPr><w:rPr><w:color w:val="FF0000"/></w:rPr></w:pPr><w:r><w:rPr><w:color w:val="FF0000"/></w:rPr><w:t>My custom</w:t></w:r><w:r><w:rPr><w:color w:val="00FF00"/></w:rPr><w:t>XML</w:t></w:r></w:p>'}

I used table'xml which you writed at stackoverflow replaced p'xml

<w:tbl>
<w:tblBorders>
  <w:top w:val="dotted" w:sz="18" w:space="0" w:color="C0504D" w:themeColor="accent2"/>
  <w:left w:val="dotted" w:sz="18" w:space="0" w:color="C0504D" w:themeColor="accent2"/>
  <w:bottom w:val="dotted" w:sz="18" w:space="0" w:color="C0504D" w:themeColor="accent2"/>
  <w:right w:val="dotted" w:sz="18" w:space="0" w:color="C0504D" w:themeColor="accent2"/>
  <w:insideH w:val="dotted" w:sz="18" w:space="0" w:color="C0504D" w:themeColor="accent2"/>
  <w:insideV w:val="dotted" w:sz="18" w:space="0" w:color="C0504D" w:themeColor="accent2"/>
</w:tblBorders>
</w:tbl>

but it doesn't work , can you give a hand . thanks .

localImageCreator problem

Hi there,

My aim is to replace a qrcode within a loop with multiple images. The application is an Apache Cordova app and therefore I need a custom way to pass the image data to DocxTemplater. I've seen some documentation on localImageCreator which looks promising but when I try to add a simple console.log line to the defaultImageCreator function, it doesn't get returned. I've added "gen:" to the beginning of my qrcode as suggested.

I was wondering if this function is still in use? Or is it dead code?

Is there any way to get around this problem?

Thank
David

{else} tag for loops

I saw #6, but I was hoping to inquire about the difficulty to add an {else} tag much like the Handlebars equivalent.

I have several variables that are laid out like is_foo_bar that are determined by a user form. While this is great for having conditional areas of content in a document, it becomes messy to try to check for the inverse of the variable. Especially if the variable is falsey to begin with.

Right now, for every variable I create a second variable that is the inverse of the first one, and prefix it with "not_".

For example (this is how I am doing things currently):

{#is_foo_bar}
  ... user picked foo is bar.
{/is_foo_bar}
{#not_is_foo_bar}
  ... user picked foo is not bar.
{/not_is_foo_bar}

What would be awesome:

{#is_foo_bar}
   ... user picked foo is bar.
{else}
  ... user picked foo is not bar.
{/is_foo_bar}

This would also come in handy if you want to display alternate content for when an array that is being looped is empty.

I would love to attempt to add this feature, but was hoping someone might be able to point me in the right direction to implement.

&, « and other symbols

Hello again!

I've tried to use string like «s» – &amp;@$ in my docx file, and I was unable to make it work correctly.

Specifically, if I pass «s» – &amp;@$ in windows-1251, docx is outputted correctly except that dash is rendered as kind of garbage:
image.

If I use utf8, I get
image

The only difference is win1251/utf8 of string "text": "«s» – &amp;@$" in Json.

Evidently, it is somehow related with #28.
Sadly, I don't know what to do with this and consider it really, really critical bug. I tried to escape contents of json values with _.escape(), but no luck.

Line breaks result in corrupted docx file

I'm using docxtemplater in the latest version of Chrome and I'm passing in some strings that were originally HTML. When there are line breaks, the output docx file is corrupted, though works fine without line breaks. When I say corrupted, I mean this happens:

screen shot 2014-04-27 at 1 25 16 pm

I can work around this by splitting on line breaks in Javascript and passing them to something like this in the template:

{#paras}
{para}
{/paras}

Is this is the recommended way, or is there something I can pass in that will convert line breaks into paragraphs in the docx template?

Permission denied in log

Hi,
I have this message in my log, but reports are correctly generated!

mkstemp("/var/www/.execoooQbuRZL") failed: Permission denied

I have no idea how explain that.
Thanks,

qr code replacing. image size

Replaced Images have the same size and aspect ratio equal to that of the qr code. Is it possible to keep the original image size.?

Default binary doesn't output any docx files

Hello again!
Don't want to be too intrusive, but somehow I was unable to create any output. Although my OS is irrelevant, I've got this bug on MacBook Air with MacOS X 10.9.2. I tried installing from npm and manually from your sources.

I've found that the problem is with DocxGen.prototype.output: file is not created due to condition if (options.download), which is obviously false when calling output like this.output(true, outputFile) (as in main.js).

This happens because output is function(options), and options gets equal to true. Of course, after that your checks like this actually do nothing, because options is true:

if (options.download == null) {
        options.download = true;
}

Sadly, it seems like some kind of code inconsistence.
By the way, this bug is present in .coffee files as well.

ability to get a jsonschema from a template for auto creating forms.

Hi,

It would be very interesting if it would be possible to create json schema based on the tags in the template. This would mean you could input them into something like alpaca and have a instant form that can be used to fill the tags with.

An added advancement would then be to add optional types (boolean for instance) to the tags ( {{name:type}} ?) so the schema could be more specific.

Just put in a docx template and you'd end up with a form and a means to download a filled docx document.

Links in docx trigerred "no data found in json file"

Here is the error, I identified that this problem is triggered in documents with links included.

docxtemplater tmp2qudpp.json
<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image15.png"/><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image16.png"/><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image17.png"/><Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image18.png"/><Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image19.png"/><Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image20.png"/><Relationship Id="rId8" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image21.png"/><Relationship Id="rId9" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image22.png"/><Relationship Id="rId10" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image23.png"/><Relationship Id="rId11" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image24.png"/><Relationship Id="rId12" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image25.png"/><Relationship Id="rId13" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" Target="header1.xml"/><Relationship Id="rId14" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" Target="footer1.xml"/><Relationship Id="rId15" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image26.png"/><Relationship Id="rId16" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image27.png"/><Relationship Id="rId17" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image28.png"/><Relationship Id="rId18" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="https://fr.wikipedia.org/wiki/" TargetMode="External"/><Relationship Id="rId19" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="mailto:[email protected]" TargetMode="External"/><Relationship Id="rId20" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" Target="header2.xml"/><Relationship Id="rId21" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" Target="footer2.xml"/><Relationship Id="rId22" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml"/><RelationshipId="rId23" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"/><Relationship Id="rId24" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/>
</Relationships>
could not decode

\docxtemplater\cli\lib\main.js:61
    if (docX[docxFileName]==undefined) throw 'no data found in json file'
                                       ^
no data found in json file

Examples path is hard coded

Why does the docxgen.js hard code to the examples folder:

DocUtils.config = {
"baseNodePath": '../../examples/',
"baseClientPath": '../examples/'
};

MS Windows' line endings in global /usr/local/bin/docxtemplater

Hi!

While trying to launch global docxtemplater binary I get
env: node\r: No such file or directory
Looks like MS Windows' file ending '\r\n'.

When I changed line endings to unix style, error disappeared.

Also, I suggest to use path.join or even path.normalize in ./docxgenNode/bin/docxgen.js like this:

path = require('path')

require(path.join(__dirname, '/../../js/docxgen.js'));
require(path.join(__dirname, '/../lib/main.js'));

The reason is that string concatenation like

require(__dirname + '/../lib/main.js');

tends to be kind of dangerous in some cases (for example, when folder separators are not in place). Just to be sure.

Doesn't work with JSZip 2.x

I suspect that the needed changes are minimal. But simply changing instances of files["test.txt"].data to files["test.txt"].asText() is not enough.

Data filters

Hello again!

Just discovered that many developers with Django/AngularJS background find it useful to use data filters in their templates.

Here is angular example and an example from Django.

I think that would be pretty nice feature as it allows to specify some basic presentation logic right in the template and to take it away from business-logic and data representation.

For example, there may be few user-specified report templates in some system, and in one of them you want to have "March 21, 2014" in header and "21.03.2014, 13:50" in report's entries. On the other hand, in another report template user may want to display dates and times in different representations.

It would not only be a disaster to send different strings by distinguishing templates in business logic, but it would just be impossible because you don't know requirements for each new template.

DocXTemplater + Express.js

Hi,
I'd like to use DocXTemplater with Express.js.
I create a route in this way:

var mime = require('mime'),
Docx = require('docxtemplater');

exports.index = function(req, res) {
var file = __dirname + '/../assets/tagExample.docx',
mimetype = mime.lookup( file );

res.setHeader('Content-disposition', 'attachment; filename=test.docx');
res.setHeader('Content-type', mimetype);

new Docx().loadFromFile( file, { async: true } ).success(function(docx) {
docx.setTags({
"first_name":"Hipp",
"last_name":"Edgar",
"phone" : "0652455478",
"description" : "New Website"
});

res.write( docx.output(false) );
res.end();

});
};

but when I try to open the just downloaded file, it comply saying it's a corrupted file. I can't either open the file with WinZip.

Any ideas?
Thanks

Support for raw XML insertion

I use your library for newsfeed reports generation, and I think it would be great to allow users to substitute ``{hisContents} tag with raw XML like this:

<w:r>
    <w:rPr>
        <w:highlight w:val="red"/>
    </w:rPr>
    <w:t>Some highlighted text</w:t>
</w:r>

It is especially useful when {content} is itself large (for example, news entry), because it makes possible for user to control underlying styles, colors and etc in some kind of large text entry. In fact, it is one of very few options for supporting such control over big runtime-generated text pieces.

If I try to do this now, my XML is surrounded by <w:r><w:t>myRawXmlHere/w:t/w:r, and MS Word obviously thinks that file is corrupt.

For distinguishing "raw" xml data I see 2 solutions: you may automatically detect XML by using something like XPath //w:r/w:t/w:r/w:t and act accordingly, or you may use some kind of special tag syntax like {@myXmlData}, which will prevent library from surrounding contents with <w:r><w:t></w:t></w:r>. I prefer latter option, because it has explicit behavior.

Although there is one problem with node replacing: it is possible that single text run contains not only you tag, but some extra data:

<w:r>
    <w:t>Your complex text i</w:t>
</w:r>
<w:r>
    <w:t>s {rawXmlText}.</w:t>
</w:r>

If we are to replace node, we will lose 's' for 'is' and '.' after our tag.
So, we have to split runs with tags like that: [left part, static] [middle part, dynamic] [right part, static], where left or right parts may be empty. After that we need to create separate run for left part (if it is non-empty), middle, and for right part. Also, we have to apply run-level formatting of the initial run to them. After that we can just replace initial run with the middle one's XML. It will lose initial formatting, of course, but I am unsure if it is bad thing for control-seeking user. Maybe it should be an option, I don't know. If it have to be there -- we can just copy non-overlapping attributes from initial run to user-supplied one.

And I don't know, but maybe the same for paragraphs?

Thank you for great library!

Data filtering and transformation

Hi!
Have you considered Angular filters?
Must be awesome feature: the same data in different representation is very common case in templating, especially with dates.
I see that it can be done on my own, but that's kind of very important feature used by too many developers - would be convenient to have angular filters by default, out of the box.
If matters, I use docxtemplater on server-side with Node, not on client. By the way, interesting for me, how typical is client-side usage of library?

Template inside template

Hi.
Do you plan any mechanism to insert one template to another?
That mechanism might be implemented by the "insert raw xml" api and another function for example:

getDocumentBody()

We would write something like:

var doc = new DocxGen().loadFromFile("xmlInsertionExample.docx");
var doc2 = new DocxGen().loadFromFile("littleTextBlock.docx");
doc.setTags({
    tag1: "Hello World",
    rawXmlTag: doc2.getDocumentBody()
});
...

What do you think about this feature?

Use Replace Variables and Raw Xml Insertion

Hi @edi9999 ,
I used code

docx.setTags(tags);
docx.applyTags({table:table,mytable:table1});

then tags show undefined . but following

docx.setTags(tags);
docx.applyTags();
docx.applyTags({table:table,mytable:table1});

instead , insert raw xml won't work .
What should I do ? thanks a lot

HyperLink inside table using looping

I'm using docxtemplater in nodejs server to generate reports. I can generate the table using looping. But I want HyperLink elemants in the table, the hyparlink styling works fine. But all the HyperLinks are pointing to the same address, Is it possible to assign different address to each Hypelink using looping.

node.js api

Could you provide direct node.js api for this library ? It would be very useful !

Doesn't work with documents containing SmartArt/Charts and qrcode test enabled

SmartArt objects, Charts are saved as separate xml files in docx. When docxtemplater tries to parse through these objects, it doesn't find the actual object, but a reference to this objects in document.xml, causing it to throw exception "tagRiD undefined!".
Example? Use any docx file with a chart in it, even without any tag to be replaced, and "config.qrcode":true in json.
Need the charts to be dynamic, so earlier workaround, #39, is of no use.

Angular parsing and sections

It seems that sections don't use the angular parsing.

Test:

var tags = {
  foo: {
    bar: true
  }
}

Document:

{#foo.bar} Hello {/foo.bar}

Output is nothing.

table styling

I really like your tool.
How does one set conditional formatting for table cells?
Alternatively, is there a workaround to embed html-snippets to the result document?

  • sr

Image from original document is lost when qrCode is true

Hello!

I have tried one of my templates in new version of docxtemplater and something strange happened: what perfectly worked in 0.2.0 is now broken.

You may download original report file and the processed one.

Now supply any first_name and be sure to set qrCode to true like this:

{
    "config.docxFile": "report1.docx",
    "config.outputFile": "output.docx",
    "config.qrcode": true,
    "first_name": "Edgar"
}

As you can see, image gets broken. However, if qrCode === false, everything works Ok.
And the most interesting part: this image + qrCode === true flawlessly worked in 0.2.0.

Looping over images

I would like to add a variable amount of images to the docx file. Is this something that can be done at the moment that I've overlooked? Or something that could be added relatively simply?

I understand the imgManager.addImageRels function adds a new image. So the next step would just add to the document.xml file with the xml linking to that new image, right?

Any help would be much appreciated.

js error in complex table template

Hi edi9999,

This is a really useful stuff... but I'm not be able to make it works with templates a little bit more complex.

Check this example: http://94.46.241.129/docxtemplater/examples/demo.html

As you can see, in this case I'm using a for-loop and "stand-alone" values for the totals of the table. However, It seems that does not work fine, not all the tags are replaced and as a result there is a javascript error.

Thanks in advance

Support for IF ELSE

Is it possible to add IF ELSE in templating? For example I want to create a table where row formatting will depend on row data.

doesn't install

Hi! I have a problem again.
Module doesn't install.
Error depends on jasmine.
If I try to install as my user

npm ERR! error rolling back Error: EACCES, unlink '/usr/bin/jasmine-node'

If I try to install as root

npm ERR! Error: Attempt to unlock jasmine-node, which hasn't been locked

Also. A co-worker of mine has tried install node.js and docxtemplater at the clean system. And docxtemplater didn't install, but other modules (for example express) has been installed successfully.

Any suggestions?

Changing the button value

I'm trying to print an invoice and a credit note using docxtemplater. Both buttons should appear in the same page, where one button says "invoice" and the other "credit". I tried modifying the js file, but the value of the button will always be either "invoice" or "credit". Can't display both at the same time.Both buttons print the correct documents. It's just the value of the buttons that can't be changed. Can you please help me with this.
Thanks

Make the loadFromFile static

Make the loadFromFile static:

eg : DocXGen.loadFromFile("test.docx",options)

instead of new DocXGen().loadFromFile("test.docx",options)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.