PDF result seems to be pixelated

Hi,


We are evaluating the CAD for Java. We’re testing DWG to PDF running against your sample codes. As we try to export it to pdf seems the quality seems to not so clear.

We’ve tinkered the options but the quality is not that good though. Here’s our code

CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setBackgroundColor(Color.getWhite());
rasterizationOptions.setPageWidth(1600);
rasterizationOptions.setPageHeight(1600);
// 2d or 3d
rasterizationOptions.setTypeOfEntities(0);
// rasterizationOptions.setTypeOfEntities(1);
rasterizationOptions.setScaleMethod(0);
// rasterizationOptions.setScaleMethod(1);
// rasterizationOptions.setContentAsBitmap(true);

// rasterizationOptions.setLayouts(new String [] {“Model”, “Layout1”});
rasterizationOptions.setLayouts(new String [] {“Model”});
rasterizationOptions.setAutomaticLayoutsScaling(true);
rasterizationOptions.setAutomaticLayoutsScaling(false);
// Create an instance of PdfOptions
PdfOptions pdfOptions = new PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);

rasterizationOptions.getGraphicsOptions().setSmoothingMode(2);
rasterizationOptions.getGraphicsOptions().setTextRenderingHint(0);
rasterizationOptions.getGraphicsOptions().setInterpolationMode(5);

Can we ask what options we could set to have a high quality pdf.

Attaching the results
Hi Banilad,

Thank you for your inquiry and sharing output PDF file.

From the sample output PDF file, it seems that you are facing very small image of the shapes in the output file issue. Please use the following code logic at your end to avoid the issue. In case the issue persists, please do not hesitate to write us back along with sample input file.

CODE:

com.aspose.cad.Image objImage = com.aspose.cad.Image.load("sample.dwg");

com.aspose.cad.imageoptions.PdfOptions options = new com.aspose.cad.imageoptions.PdfOptions();

com.aspose.cad.imageoptions.CadRasterizationOptions cadOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions();

cadOptions.setDrawType(com.aspose.cad.fileformats.cad.CadDrawTypeMode.UseObjectColor);
cadOptions.setCenterDrawing(true);
cadOptions.setDrawType(com.aspose.cad.fileformats.cad.CadDrawTypeMode.UseObjectColor);
cadOptions.setLayouts(
new String[] { "Model" }
);
cadOptions.setDrawType(com.aspose.cad.fileformats.cad.CadDrawTypeMode.UseObjectColor);
cadOptions.setPageWidth(objImage.getWidth());
cadOptions.setPageHeight(objImage.getHeight());
cadOptions.setLayouts(
new String[] { "Model" }
);
cadOptions.setScaleMethod(com.aspose.cad.fileformats.cad.ScaleType.None);

options.setVectorRasterizationOptions(cadOptions);
objImage.save("sample_dwg.pdf", options);

Thank you for your reply.


Further on my previous question, when we convert a DWG to pdf, the pdf generated appears to be nothing more than an image (png/jpeg). The pdf is pixelated, I would have thought the dwg would have been converted to a vector pdf, with selectable text etc.

Are we doing something wrong or does the software simply convert the dwg to an image?


Update: We’ve used the following options and the quality has gotten a lot better. Is there also a way we can modify change the fonts and change the font style (italic, bold, regular etc).
We followed this page http://www.aspose.com/docs/display/imagingjava/Substituting+Fonts+while+Converting+CAD+Drawings to change the fonts.
Attaching some jpegs when we zoom in on some of the texts.

Hi Banilad,

Thank you for writing us back.

This is to update you that no such API is available to manipulate the font style like italic, bold and regular etc. Please forward us your sample input file to regenerate the issue at our end. We will look into it and update you with our findings via this forum thread.

Hi ikram.haq,


Thank you for your reply.

Attaching the test dwg.

Also attaching some screenshots of the text from dwg and the generated pdf

We also have a question from our previous post. Here it is

Further on my previous question, when we convert a DWG to pdf, the pdf generated appears to be nothing more than an image (png/jpeg). The pdf is pixelated, I would have thought the dwg would have been converted to a vector pdf, with selectable text etc.

Are we doing something wrong or does the software simply convert the dwg to an image?





Thanks.
Hi Banilad,

Thank you for your inquiry and sharing sample.

Please use the functionality setCenterDrawing and set it to true as used in the following sample code snippet. Furthermore there are 2 different ways in which Aspose.CAD converts the drawing to PDF format.
  1. Rasterization
  2. Vector

While converting CAD drawing to PDF we use CadRasterizationOptions. CadRasterizationOptions has a property called ContentAsBitmap. In case this property is set to true raster image will be generated in result. In case it is not set as true then generated PDF will be vector PDF. Please note that by default it is set as false hence generate vector PDF.

Hope the above information helps. Feel free to contact us in case of any query or comments.

CODE:

com.aspose.cad.Image objImage = com.aspose.cad.Image.load("test.dwg"); com.aspose.cad.imageoptions.CadRasterizationOptions cadOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions();

cadOptions.setCenterDrawing(true); cadOptions.setScaleMethod(com.aspose.cad.fileformats.cad.ScaleType.ShrinkToFit); //cadOptions.setDrawType(com.aspose.cad.fileformats.cad.CadDrawTypeMode.UseObjectColor);
cadOptions.setLayouts( new String[] { "Model" } ); cadOptions.setPageWidth(10000); cadOptions.setPageHeight(8000); cadOptions.setTypeOfEntities(com.aspose.cad.imageoptions.TypeOfEntities.Entities2D); cadOptions.setBackgroundColor(com.aspose.cad.Color.getWhite());
com.aspose.cad.imageoptions.PdfOptions options = new com.aspose.cad.imageoptions.PdfOptions();
options.setVectorRasterizationOptions(cadOptions);

objImage.save("test_dwg.pdf", options);

Hi Ikram,


Thank you for your response.

The code snippet you sent helped in improving the generated PDF.

We have another question regarding on another DWG file, when we convert we are always getting an exception, Caused by: class com.aspose.cad.internal.Exceptions.Exception: Cannot process loading further due to incorrect file format structure.

We’ve attached the DWG file that spits the error.

Best Regards



Hi Ikram ul Haq,

Any updates on the problem we posted on our previouew reply.

It's about the "Cannot process loading further due to incorrect file format structure."

Thanks.



Hi Banilad,

Thank you for your inquiry and sharing sample.

We have tried to regenerate the issue at our end by using the sample provided by you. We are able to regenerate the issue. The issue has been logged into our system with ID CADJAVA-52. Our product team will further look into it. We will update with their findings via this forum thread.

Furthermore we have tried to open the DWG file in Autodesk Truview, it is showing error message:

SHX files, called shape files, are used as text fonts or sysmbol fonts. the missing SHX files were not transferred with the drawing.

Hi Banilad,

This is to update you that our product team is investigating the issue. It was found that the test file supplied by you was not created in Autocad. It cannot be converted to versions R2000, R14, R13. In case we try to it in versions R2004/R2010/R2013, it is showing warning messages. Our product team is unable to read decompression data in the DWG file.

Please forward us a valid sample file.

Hi Ikram,


We’ve checked it’s Autocad and it’s 2010 version. We checked it by opening it in notepad it displays the AC1024.

Also attaching a screenshot
What are the possible causes where it spits out the It’s about the “Cannot process loading further due to incorrect file format structure.” message during conversion to pdf?
Hi Banilad,

Thank you for writing us back.

Our product team has further investigated the issue. Investigation shows that the issue persists. Our product team will now fix the issue. Please spare us some time. We will update you with the progress via this forum thread.

Hi Ikram,


Thank you for your response.

I attached a file, where the CAD.Java library converts the dwg to pdf but the generated pdf is corrupt.

But the other files are fine but only this particular dwg. The library didn’t spit any error.

Attaching the dwg file

Thanks.
Hi Banilad,

Thank you for writing us back.

The information has been forwarded to product team. They will use it while investigation.

The issues you have found earlier (filed as CADJAVA-52) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.