Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert PLT to PDF or PNG JPG Image Programmatically using Java
// Load input PLT file
Image image = Image.load(PLTPathToFile);
// Setting Image Options with ImageOptionsBase
ImageOptionsBase imageOptions = new JpegOptions();
// Initialize CadRasterizationOptions object
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);
cadRasterizationOptions.setPageHeight(1600);
cadRasterizationOptions.setPageWidth(1600);
cadRasterizationOptions.setBackgroundColor(Color.getGray());
imageOptions.setVectorRasterizationOptions(cadRasterizationOptions);
// Save PLT to output Image PNG, JPG, etc
image.save(dataDir + "50states.jpg", imageOptions);
// Load input PLT file
Image image = Image.load(PLTPathToFile);
// Setting PdfOptions object
PdfOptions pdfOptions = new PdfOptions();
// Specify CadRasterizationOptions instance
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);
cadRasterizationOptions.setPageHeight(1600);
cadRasterizationOptions.setPageWidth(1600);
cadRasterizationOptions.setBackgroundColor(Color.getGray());
pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions);
// Saving PLT to output PDF
image.save(dataDir + "50states.pdf", pdfOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment