Convert PLT to PDF in Java

This brief topic explains how to convert PLT to PDF in Java. It covers precise steps to configure the environment including an algorithm and a working code snippet to create a PLT to PDF converter software in Java. Moreover, you don’t require any third-party software to perform the required conversion.

Steps to Export PLT to PDF in Java

  1. Prepare the environment by adding Aspose.CAD for Java using the repository manager plugin to convert PLT to PDF
  2. Access the source PLT file using the Image class object
  3. Create an instance of the PdfOptions class and create the CadRasterizationOptions class object to set the page size
  4. Configure the VectorRasterizationOptions property for specific values
  5. Export the PLT file to PDF format using the save method

The above steps entail how to convert PLT files to PDF in Java. We will start by accessing the source PLT file from the disk using an instance of the Image class and different rendering options will be set to customize the PLT conversion. Finally, we will render the PLT as a PDF document and save it to the disk or a memory stream.

Code to Export PLT to PDF in Java

import com.aspose.cad.Image;
import com.aspose.cad.License;
import com.aspose.cad.imageoptions.CadRasterizationOptions;
import com.aspose.cad.imageoptions.PdfOptions;
public class ConvertPLTToPDF {
public static void main(String[] args) throws Exception { // main method to convert PLT to PDF
String path = "/Users/KnowledgeBase/TestData/";
// Set the license to convert PLT to PDF
License licensePLTtoPDF = new License();
licensePLTtoPDF.setLicense(path + "Conholdate.Total.Product.Family.lic");
// Load the source PLT file from the disk
Image pltImage = Image.load(path + "50states.plt");
// Create the PdfOptions instance for the output PDF file
PdfOptions pdfOpts = new PdfOptions();
// Create an object of the vector rasterization options
CadRasterizationOptions rasterOpts = new CadRasterizationOptions();
rasterOpts.setPageWidth(500);
rasterOpts.setPageHeight(500);
pdfOpts.setVectorRasterizationOptions(rasterOpts);
// Convert PLT to PDF
pltImage.save(path + "50states.pdf", pdfOpts);
}
}

This example code converts AutoCAD PLT to PDF in Java. The source PLT file is accessed using the Image class and then the CadRasterizationOptions class instance is used to set the required page size of the output PDF document. Finally, the required overload of the save method is invoked to render the PDF document. Moreover, you can also set watermark text, watermark color, rotation, and other properties of the PdfOptions class as per your requirements.

This topic has encompassed the details of converting PLT to PDF in Java. However, if you want to learn about DWG to PDF conversion, read the article on how to convert DWG to PDF in Java.

 English