Creating PDF document from Word document using java api

久未见 提交于 2019-12-24 00:58:49

问题


In one of my requirement I have to create a PDF from word document such that

1) There will be a page number on every page.

2) There will be line number for every line, starting from line no as 1 for each page.

Our application is written in java so Java API will be more helpful. But if it is more convenient in any other language that will be OK.


回答1:


Here is a link to the most common Java PDF API :) http://java-source.net/open-source/pdf-libraries IText is the most famous one, This is the link for IText http://itextpdf.com/ I hope that I helped :)




回答2:


Since word file cant be read like a .txt file , you will need 2 APIs.

One to read data from the doc file and another to write that data into pdf file.

Now to read data from the doc file you can use APACHE-POI.

and to write that data into pdf file you can use ITEXT.




回答3:


I suggest JODReports or Docmosis since you want to start with a word document. You can dynamically insert numbered records and page breaks from a Java api so it sounds like they will be able to meet your requirements.

You haven't indicated why you want to start with a word document. If you are strictly generating a document, you could possibly drop that requirement and use iText or docx4j.




回答4:


You can use Apache FOP(http://xmlgraphics.apache.org/fop/) only one thing I see last update on Oct 2012 for 1.1 release. But still issue are open.




回答5:


You could try docx4j, although you would need to make a minor enhancement to support line numbering on every line, and possibly more problematically, probably use a commercial XSL FO processor.

docx4j uses XSL FO for PDF output, and line numbering isn't part of the 1.0 spec. (It is part of the XSL 2.0 requirements spec)

This means you'd have to use a XSL FO processor which supports a vendor-specific extension, for example Antenna House

UPDATE 2016 04

From v3.3.0, docx4j defaults to using our commercial converter, which you can try at http://converter-eval.plutext.com/



来源:https://stackoverflow.com/questions/9923910/creating-pdf-document-from-word-document-using-java-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!