In this quick tutorial, you will learn to convert SVG to PDF using Java with the help of just a couple of lines of code. It requires loading the SVG file and then saving it on the disk as a PDF. You can change SVG to PDF using Java along with the option to customize the output PDF in a variety of ways.
Steps to Export SVG to PDF using Java
- Configure your project to use Aspose.Imaging from the Maven repository
- Load the source SVG file using the Image class object
- Instantiate the PdfOptions class object to configure the output PDF
- Save the image as PDF using the specified PDF options
These steps guide to convert SVG file to PDF using Java by sharing configuration information and then simple to-do list to accomplish the task. First, you have to load the source SVG file and then instantiate the PdfOptions class object that contains options to set page size, PDF core options, and PDF document information to name a very few.
Code to Convert From SVG to PDF using Java
This code converts SVG to PDF using Java and provides options to set PDFCoreOptions using the PdfOptions class object. You can set bookmarks outline level, compression, expanded outline levels, heading outline levels, JPEG quality and PDF compliance properties using the PDFCoreOptions. Similarly, you can set the output PDF file author name, keywords, subject, and title using the PdfDocumentInfo property in the PdfOptions class object.
We have learned to convert SVG to PDF here however if you want to convert SVG to PNG, refer to the article on how to convert SVG to PNG using Java.