Free Support Forum - aspose.com

DWG to PDF: Lines and elements not drawn, and wrong size

Hi,

While testing the conversion of DWG files to PDF, using Aspose.CAD for Java v17.4, I found many issues, firstly about lines or elements not drawn, secondly about the wrong size for the result.

Here is the code you can use to test it:

for (String fileName: Arrays.asList("pump.dwg", "street.dwg")) {
	try (Image image = CadImage.load(fileName)) {
		CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
		// A4 format landscape
		rasterizationOptions.setPageWidth(210);
		rasterizationOptions.setPageHeight(297);
		rasterizationOptions.setUnitType(UnitType.Millimeter);
		rasterizationOptions.setTypeOfEntities(TypeOfEntities.Entities2D);
		rasterizationOptions.setCenterDrawing(true);
		rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);
		rasterizationOptions.setLayouts(new String[]{"Model"});

		PdfOptions options = new PdfOptions();
		options.setVectorRasterizationOptions(rasterizationOptions);
		image.save(fileName + ".pdf", options);
	}
}

You can find the DWG files used in this code in the joined files.zip file.

I’ve seen 3 issues in the resulting files:

  • In the produced file “pump.dwg.pdf”, a lot of elements are not drawn: some simple lines, the hatch lines, the numbered bubbles, the list of items on the left, etc…
  • In the produced file “street.dwg.pdf”, the drawn model is very small in the center of the page, so small that it isn’t usable. I expected it to fit the page. I tried to use CadRasterizationOptions.setAutomaticLayoutsScaling() and CadRasterizationOptions.setNoScaling(), but it didn’t produced the expected result.
  • The produced file “street.dwg.pdf” doesn’t have the expected page size. While looking at Acrobat Reader > File > Properties, I get a page size of 141.32 x 199.86 in / 3589.4 x 5076.5 mm. I tried to use PdfOptions.setResolutionSettings(), but it didn’t changed anything.

A last question: I’ve seen you published release notes for v17.8, but it isn’t available for download yet (see here). Will this version be available soon ? Is there a chance it could fix my issues ?

Best regards

@l.istin,

I have worked with sample files hared by you and have been able to observe the issues specified. An issue with ID CADJAVA-158 has been added to investigate and resolve issues related to missing elements in pump.dwg.pdf. A separate issue with ID CADJAVA-159 has been created to investigate and resolve the issue related to page size in exported street.dwg.pdf. This thread has been linked with the issues so that you may be automatically notified once the issues will be fixed.

I also like to add further here that at present we have not released Apose.CAD for Java 17.8. We may share notification with you once the product will be shared online.

@l.istin,

For your following issue, it has been observed that the generated file has 5 referenced files and we need all of of them to be attached here to reproduce the issue. Can you please share them with us.

Hi,
In our use cases, the referenced files can be missing. The file I attached to this issue was uploaded alone by our customer. We are using Aspose.CAD to generate a preview supported by Web browsers from single files uploaded in our application.
In such a case, we expect the referenced files to be ignored, but it shouldn’t stop the rendering process in the middle.
Other tools/libraries, such as Autodesk tools or Teigha tools/libraries, are rendering all the content contained in the file properly even if the referenced files are missing.
If Aspose.CAD can’t be fixed to render these cases properly, we will have to consider to replace it by one of these tools.
Best regards

@l.istin,

We really wish to help you out and resolve the issue on your end. I have shared your comments related to availability of reference files to properly investigate the issue. If there will be any chance to investigate the issue without provision of all reference files then we will do that on our end. Otherwise, we will request you again for availability of reference files if we are unable to reproduce the issue.

The issues you have found earlier (filed as CADNET-420) have been fixed in Aspose.CAD for .NET 17.12. Please try using the latest release version and in case you experience any issue or you have any further query, please feel free to contact.

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

Has issue CADJAVA-159 been resolved yet? We are still seeing the mentioned behaviour in Version 19.9.

@regnete,

I like to share the issue has been resolved since Aspose.CAD for Java 17.12. If you are still seeing the issue please share the source files, used sample code and generated output for reference.

Thank your for your reply.

The issue is still there or there again.

I already started a new thread regarding this and other issues.
Aspose Java - CadRasterizationOptions - How to specifypage size. So I won’t continue here.

@regnete,

Thanks for contacting us. I have responded to you in your other thread.