Reputation: 3429
I am trying to convert a docx document containing a logo to a pdf document. I have tried this :
FileInputStream in=new FileInputStream(fileInput);
XWPFDocument document=new XWPFDocument(in);
File outFile=new File(fileOutput);
OutputStream out=new FileOutputStream(outFile);
PdfOptions options=null;
PdfConverter.getInstance().convert(document,out,options);
But in the pdf document the logo is not at the right place.
Is there a way to create a PDF that is exactly the same as the docx document?
Upvotes: 2
Views: 806
Reputation: 803
Could be document4j an option? It delegates the convertion to the native application.
This is achieved by delegating the conversion to any native application which understands the conversion of the given file into the desired target format.
File wordFile = new File( ... );
File target = new File( ... );
IConverter converter = ... ;
Future<Boolean> conversion = converter
.convert(wordFile).as(DocumentType.MS_WORD)
.to(target).as(DocumentType.PDF)
.prioritizeWith(1000) // optional
.schedule();
You can quickly test if the convertion fit your requirement with the "Local demo" on a Windows machine with Word and Excel installed:
git clone https://github.com/documents4j/documents4j.git
cd documents4j
cd documents4j-local-demo
mvn jetty:run
Then go to http://localhost:8080
See the full documentation here : http://documents4j.com/#/
Upvotes: 1