XHTML is a text-based file format with markup in the XML format. This format is widely used because of being generic and involves less scripting. Whereas, PDF files are fixed-layout format files that are popularly used because of being platform-independent. In certain cases, you may need to convert XHTML files to PDF format. In accordance with such use cases, this article demonstrates how to convert XHTML to PDF format in Java.
- XHTML to PDF Converter – Java API Installation
- Convert XHTML to PDF File Programmatically using Java
XHTML to PDF Converter – Java API Installation
Aspose.HTML for Java API supports HTML, MHTML, PDF, and many other file formats. You can quickly configure the API by downloading its JAR file from the New Releases section, or via the following configurations to access it from the Aspose Repository:
<repositories> <repository> <id>snapshots</id> <name>repo</name> <url>http://repository.aspose.com/repo/</url> </repository> </repositories>
<dependencies> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-html</artifactId> <version>21.12</version> <classifier>jdk17</classifier> </dependency> </dependencies>
Convert XHTML to PDF File Programmatically in Java
The steps below elaborate on how to convert an XHTML file to PDF format programmatically in Java:
- Load the input XHTML file.
- Create a PdfSaveOptions class object.
- Convert the XHTML file to PDF format.
The code snippet below demonstrates how to convert XHTML to PDF format programmatically in Java:
Explore Aspose.HTML for Java
You may take a look at the documentation section to explore various other features of the API. Moreover, other helpful topics providing the information about release notes as well as the beginner’s guide details are also covered accordingly.
In conclusion, you have learned how to convert XHTML to PDF format. This conversion is helpful in different scenarios like when you need to share the data with many people. Furthermore, in case you have any inquiries or ambiguities, please feel free to write to us at the forum.