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.01k stars 348 forks source link

Convert to PDF #153

Closed natcohen closed 9 years ago

natcohen commented 9 years ago

I know it's out of scope but it would be amazing to be able to use this library, modify docx templates and then convert them into PDF (wysiwig and all in browser...). Anyway, amazing job!

edi9999 commented 9 years ago

It is maybe possible to port parts of libreoffice into the browser using emscriptem.

Then use PDF.js for viewing the document. However it wouldn't be very easy to write a wysivig editor on top of that.

natcohen commented 9 years ago

@edi9999 sounds easier than it really is... Converting with emscripten is a hassle (if you have experience with it, I would be happy to hear any advice you have or if you're willing to start it, I'll be the first to help!). LibreOffice is moving to the cloud by the end of the year so it won't be a problem to implement an editor. If you're talking about a pdf editor, there is also a solution (http://www.codeproject.com/Articles/466362/Blend-PDF-with-HTML).

Anyway, I really think docxtemplater + docx2pdf is the ultimate solution to generate documents without re-designing a document with pdfKit or jsPDF (which can be time consuming and not very efficient for complex layout). It would offer much more flexibility and open for new applications. Docxtemplater would really benefit from that because ultimately it is very rare for an app/website to output a docx file.

edi9999 commented 9 years ago

Yes I know that converting with emscriptem is very difficult, however I've never done it before. I guess with a huge codebase such as the one of libre office, it would be an enormous amount of time.

You're talking about docx2pdf, but is this a "hypothetical tool" or something that really exists ?

I also think that it would simplify things a lot if we could do this PDF conversion step in the browser as well

natcohen commented 9 years ago

Unfortunately it's hypothetical...

vishsid73 commented 8 years ago

This is really cool feature.....if can somehow create generate a pdf from the doc template will be great. This should be reopened and added as a feature request.

edi9999 commented 8 years ago

This issue is out of scope with this project. Creating a docx to pdf renderer totally in JS is an enormous amount of work, probably more than 10 times the amount of work of this library.

plutext commented 5 years ago

@edi9999 and anyone who stumbles across this, there is now docx-wasm which can convert the docx to PDF; it performs the conversion locally. (Freemium model library).

natcohen commented 5 years ago

@plutext That's amazing if it does what I think it does :)

PS you should fix the link, "which" at the end should be removed

Aarbel commented 5 years ago

great insight, thank you @plutext, will try it in the future. They also have a client side example : https://github.com/NativeDocuments/docx-wasm-client-side

softboy99 commented 3 years ago

Hi, @plutext, @Aarbel NativeDocument.com cannot be openned, the project docx-wasm may has been died. It will be an amazon things if we could do that in browser, all of the reporting tools,like crystal report, ssrs,fastreport etc will be ened.

softboy99 commented 3 years ago

Hi, @edi9999, can check the pdfmake to which have api to wirte pdf https://github.com/bpampuch/pdfmake

edi9999 commented 3 years ago

Yes, one way is to forget about docx completely, however it makes it not possible to use Word to create your templates (which is the power of this library).

edi9999 commented 3 years ago

After many years, I still don't have a perfect solution for this.

PDFTron works quite well as far as I can tell.

nirkons commented 2 years ago

if anyone is looking for this, you can use libreoffice like this lowriter --convert-to pdf /path or https://github.com/unoconv/unoserver which launches a libreoffice server and also allows you to specify input/output filenames and paths

softboy99 commented 2 years ago

Hi @nirkons, The industry needs an lightweiht solution without any 3rd party software based on docx specification and pdf specification only. It can be library or framework other than software application

softboy99 commented 1 year ago

@edi9999 , Tried pdftron, there're still many formation issue caused docx file different with pdf file