Convert Docx to PDF in Java with a single line of code

Sferyx JSyndrome PDF Generator and Converter


Advanced Java Docx PDF Generator and Converter component - convert Word Docx files to PDF

Sferyx PDF Generator Component is a powerful Java Docx to PDF Converter and Generator library. It can convert easily Word Docx to PDF in any Java Application - Java Swing, JavaFX, SWT Eclipse and also Oracle Forms and produces perfectly paginated documents preserving the formatting including the page breaks, headers, footers and page numbers. With only a few lines of Java code is possible to generate complex PDF files from almost any Word Docx file and the resulting PDF can be written to a local file, java.io.OutputStream or shown automatically inside the PDF viewer. The Sferyx PDF Generator component is ready for use out of the box and does not depend on external packages - it will work with any JRE/JDK 1.4 or higher.

Convert Docx to PDF Java

 

All Sferyx products are signed with  
Trusted Code Signing Security Certificate from Thawte

Download Sferyx PDFGenerator Java Docx to PDF Component Java Docx to PDF Converter
Version 21.0

Sferyx JSyndrome PDF Generator Component Edition : Download Sferyx PDFGenerator - PDFGeneratorDemo.zip
 

Convert Word Docx to PDF in Java from URL to java.io.File

To convert the Docx to PDF simply use the method below and will generate the file using the standard page format string such as "A4", "Letter" etc. and and save the file to the specified OutputStream or File and page orientation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat. The destinationFile parameter is a java.io.File object:

 

import sferyx.administration.pdfgenerator.*;

PDFGenerator pdfGenerator=new PDFGenerator();
pdfGenerator.setMarginsForStandardPageFormat (10,10,10,10);
pdfGenerator.setCharset ("utf-8"); Will embed all fonts and generate PDF/A compliant file and will add support for non-latin languages.
pdfGenerator.generatePDFFromDocxURL ("http://your_url_here.docx", destinationFile, "Letter", "Portrait");

or using the file name as String:

 

import sferyx.administration.pdfgenerator.*;

PDFGenerator pdfGenerator=new PDFGenerator();
pdfGenerator.setMarginsForStandardPageFormat (10,10,10,10);
pdfGenerator.setCharset ("utf-8"); Will embed all fonts and generate PDF/A compliant file and will add support for non-latin languages.
pdfGenerator.generatePDFFromDocxURL ("http://your_url_here.docx", "c:/pdfgenerator-test1.pdf", "A4", "Portrait");

Convert Word Docx to PDF in Java from URL to java.io.OutputStream

It will convert the specified Docx document to PDF using the standard page format string such as "A4", "Letter" etc. and and save it to the specified OutputStream and page orientation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat. This method will recognize automatically if the document is HTML, Docx, RTF, TXT or image and will convert it accordingly. To use this automatic conversion the URL must end with the corresponding extension like docx, txt, rtx, jpeg, gif, png etc.

 

pdfGenerator.generatePDFFromURL ("http://your_url_here/file.docx", destinationStream, "Letter", "Portrait");


If you want to include automatically all TTF fonts inside the PDF/A document or you are using non western languages or special characters you should use the following method:

 

pdfGenerator.setCharset ("utf-8");


For generation of documents in Chinese language use the following setting:

 

pdfGenerator.setCharset ("ISO-10646-UCS-2");

Convert Word Docx to PDF in Java from URL with different java.awt.print.PageFormat dialog options


Converts automatically the Docx URL to PDF and generates the file using the given Page Format and File dialog options. It will display a PageFormat dialog and File dialog for saving the generated file. This method will recognize automatically if the document is HTML, Docx, RTF, TXT or image and will convert it accordingly. To use this automatic conversion the URL must end with the corresponding extension like docx, txt, rtx, jpeg, gif, png etc. 
 

pdfGenerator.generatePDFFromURL ("http://your_url_here/file.docx");


It will display a PageFormat dialog and save the file to the specified destination file. This method will recognize automatically if the document is HTML, Docx, RTF, TXT or image and will convert it accordingly. To use this automatic conversion the URL must end with the corresponding extension like docx, txt, rtx, jpeg, gif, png etc.   

 

pdfGenerator.generatePDFFromURL ("http://your_url_here/file.docx","c:/pdfgenerator-test1.pdf");


Generates or converts PDF automatically for the URL source. It will generate the file using the given java.awt.PageFormat and save the file to the given destination file. This method will recognize automatically if the document is HTML, Docx, RTF, TXT or image and will convert it accordingly. To use this automatic conversion the URL must end with the corresponding extension like docx, txt, rtx, jpeg, gif, png etc.   

 

pdfGenerator.generatePDFFromURL ("http://your_url_here/file.docx", "c:/pdfgenerator-test1.pdf", new java.awt.PageFormat());

 

Generates or converts PDF automatically for the  html content. It will generate the file using the given standard page format string such  as "A4", "Letter" etc. and and save the file to the given File and page orientation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat

 

pdfGenerator.generatePDFFromDocxURL ("http://your_url_here/file.docx", "c:/pdfgenerator-test1.pdf", "A4", "Portrait");

or

pdfGenerator.generatePDFFromURL ("http://your_url_here/file.docx", "c:/pdfgenerator-test1.pdf", "Letter", "Landscape");
 

 

Customers

Sferyx customer base counts more than 1000 corporate customers and institutions from over 40 countries and different industrial sectors as follows: Media and publishing companies, Internet Service Providers, Research  Labs, Fortune 500 companies, Universities, Colleges and Schools, Software Developers, Content Management Systems developers, Web design agencies.

More than 1000 corporate customers, among them:

 

| Home | Users Manual | LicenseDemo & Download

Copyright 2001-2021 Sferyx Srl. All rights reserved. Sferyx and the Sferyx logo are registered trademarks of Sferyx Srl. http://www.sferyx.com