Quality of converted PDF from DWG file is not good

Hello Team,

One of our client complained about converted PDF file from DWG.
I am uploading the sample DWG file heDownloads.zip (697.2 KB)
re. Generated PDF quality is not good.
I have also uploaded generated PDF file.
Kindly help us to resolve quality issue.

We are using below code to convert DWG to PDF:

public File generatePdf(File pdfFile) {
try(Image cadImage = Image.load(file.getAbsolutePath())) {
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setPageWidth(cadImage.getWidth());
rasterizationOptions.setPageHeight(cadImage.getHeight());
rasterizationOptions.setAutomaticLayoutsScaling(true);
rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);

        rasterizationOptions.setNoScaling(false);
        // Set Graphics options
        rasterizationOptions.getGraphicsOptions().setSmoothingMode(SmoothingMode.HighQuality);
        rasterizationOptions.getGraphicsOptions().setTextRenderingHint(TextRenderingHint.AntiAliasGridFit);
        rasterizationOptions.getGraphicsOptions().setInterpolationMode(InterpolationMode.HighQualityBicubic);


        // Create an instance of PDF options class
        PdfOptions pdfOptions = new PdfOptions();
        pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
        // Export to PDF by calling the Save method
        cadImage.save(pdfFile.getAbsolutePath(), pdfOptions);
        return pdfFile;

Regards,
Aniket

@aniketvk,
Hello, please, test, whether this is useful:

RasterizationQuality quality = new RasterizationQuality();
quality.setTextThicknessNormalization(true);
rasterizationOptions.setQuality(quality);

@Oleksii.Gorokhovatskyi: Thank you for your quick response.
Generated PDF quality is quite improved after applying above code changes.
Thanks your your help.
Regards,
Aniket

1 Like