open-xml-templating / docxtemplater

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
https://www.docxtemplater.com
Other
3.07k stars 350 forks source link

LibreOffice Manual Page Breaks #700

Open jcalfee opened 1 year ago

jcalfee commented 1 year ago

Environment

How to reproduce my problem :

My template is the following : multidoc.zip

  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2023-02-18 19:18   multidoc/
     6356  2023-02-18 18:29   multidoc/input.docx
      461  2023-02-18 18:41   multidoc/render.js
       71  2022-07-12 08:43   multidoc/nodemon.json
     7382  2023-02-18 19:13   multidoc/output-expected.docx
    23374  2023-02-18 18:41   multidoc/output.docx
const fs = require('fs')
const Docxtemplater = require('docxtemplater')

const content = fs.readFileSync(__dirname + "/input.docx", "binary")

const PizZip = require('pizzip')
const zip = new PizZip(content)

const doc = new Docxtemplater(zip)

doc.render({
  Letters: [null, null] // Two
})

const buf = doc.getZip().generate({type: 'nodebuffer'})

const template = __dirname + '/output.docx'
console.log(`writing ${template}`)
fs.writeFileSync(template, buf)

I would expect it to :

Recognize LibreOffice Manual Page Breaks

image

walk through video multidoc.zip

edi9999 commented 1 year ago

I will be going in the detail of the video if what I suggest does not work, but my main idea would be to try to use the paragraphLoop option :

like this :

const doc = new Docxtemplater(zip, {
    paragraphLoop: true,
});

Please let me know if that works

edi9999 commented 1 year ago

I now have seen the video, the fix I suggested is wrong, it has to do with something else.

I have to check that more deeply, it is not that easy so it might take some time to get a fix or an explanation (maybe it is too complex to handle in the free version).

jcalfee commented 1 year ago

We do our best to keep open source on the servers, however, I can ask the group if we can approve a gift / donation. You have certainly already earned it. I do that anyways. I have crypto on hand and they have company card. Plus, I hope this server's your interest and the open source community at the same time.