Bug in Java version

Hi,


I’m trying to convert the attached DWG images to PDF with the code below, but I get multiple issues, either file not supported or the exception below:

com.aspose.cad.Image image = com.aspose.cad.Image.load(path);

// Create an instance of CadRasterizationOptions and set its various properties
com.aspose.cad.imageoptions.CadRasterizationOptions rasterizationOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions();
rasterizationOptions.setBackgroundColor(com.aspose.cad.Color.getWhite());
rasterizationOptions.setPageWidth(1600);
rasterizationOptions.setPageHeight(1600);

// Create an instance of PdfOptions
com.aspose.cad.imageoptions.PdfOptions pdfOptions = new com.aspose.cad.imageoptions.PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);

image.save(pdfPath);

Exception in thread “main” class com.aspose.cad.internal.fR.t: The method or operation is not implemented
com.aspose.cad.fileformats.cad.CadImage.saveData(Unknown Source)
com.aspose.cad.DataStreamSupporter.a(Unknown Source)
com.aspose.cad.DataStreamSupporter.save(Unknown Source)

I’ve tried the same with multiple different DXF file (https://www.dropbox.com/sh/3up7wqqjm758au0/AAAkHtfQ0LpBes4VYWKLcz8va?dl=0), but everything fails with the same exception. Why none of my CAD files works?


Exception in thread “main” class com.aspose.cad.internal.fR.t: The method or operation is not implemented
com.aspose.cad.fileformats.cad.CadImage.saveData(Unknown Source)

Thanks,
Mariusz

I’ve tried dozens of AutoCAD files downloaded from multiple sites and every single one fails with the same exception. Is there anything working with the initial release? :slight_smile:


http://justcad.com/downloads.html
https://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/autocad-sample-files.html
http://www.signtorch.com/store/Free-Vector-DXF-Art-Samples
Hi Mariusz,

Thank you for your inquiry.

This is to update you that the issue is actually with the code snippet that you are using. Please use the following code snippet to convert the DWG to PDF format. You can find more details on the release notes page and on the link DWG Drawings.

CODE:

String sourceFile = "CAD_demo_1.dwg";
com.aspose.cad.fileformats.cad.CadImage image =
(com.aspose.cad.fileformats.cad.CadImage) com.aspose.cad.fileformats.cad.CadImage.load(sourceFile);

//Create an instance of CadRasterizationOptions and set its various properties
com.aspose.cad.imageoptions.CadRasterizationOptions rasterizationOptions =
new com.aspose.cad.imageoptions.CadRasterizationOptions();
rasterizationOptions.setPageWidth(1600);
rasterizationOptions.setPageHeight(1600);
rasterizationOptions.setTypeOfEntities(TypeOfEntities.Entities3D);
//Create an instance of PdfOptions
com.aspose.cad.imageoptions.PdfOptions pdfOptions = new com.aspose.cad.imageoptions.PdfOptions();
//Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
//Export the CAD to PDF
image.save("CAD_demo_1.pdf", pdfOptions);

That doesn’t make any difference. I use the code below and e.g. the attached DXF file. The exception is still the same:


CODE:

com.aspose.cad.Image image = com.aspose.cad.Image.load(path);

// Create an instance of CadRasterizationOptions and set its various properties
com.aspose.cad.imageoptions.CadRasterizationOptions rasterizationOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions();
rasterizationOptions.setTypeOfEntities(TypeOfEntities.Entities3D);
rasterizationOptions.setPageWidth(1600);
rasterizationOptions.setPageHeight(1600);

// Create an instance of PdfOptions
com.aspose.cad.imageoptions.PdfOptions pdfOptions = new com.aspose.cad.imageoptions.PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);

image.save(pdfPath);

EXCEPTION:

Exception in thread “main” class com.aspose.cad.internal.fR.t: The method or operation is not implemented
com.aspose.cad.fileformats.cad.CadImage.saveData(Unknown Source)
com.aspose.cad.DataStreamSupporter.a(Unknown Source)
com.aspose.cad.DataStreamSupporter.save(Unknown Source)
com.generiscorp.renderer.CRSTest.main(CRSTest.java:33)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)

Thanks,
Mariusz

BTW, the original code sample I used is exactly from the page you mentioned. And it is exactly the same.

Hi Mariusz,

Thank you for writing us back.

Please have a look at the very last line of the code snippet. Your version of code is passing a single parameter to the Save method of the Image class object where as mine version is passing 2 parameters to the Save method of the Image class object i.e. path & name of the destination file and object of imageoptions base class.


// Your version of code
image.save(pdfPath);
// My version of code
image.save("CAD_demo_1.pdf", pdfOptions);

Ah, OK, my bad, thanks. But anyway, error handling should be better in this case :slight_smile:

Nevertheless I run conversion of several files, you can find the files and the PDF output here:

https://www.dropbox.com/sh/tcj0rx8a83msqd5/AAAmU2q9R61RlZHSAdASXn3La?dl=0

And the results are not as expected.

Two files conversion failed: architectural_-_annotation_scaling_and_multileaders.dwg and torso_uniform.dxf.
The others PDFs contain usually multiple pages with strange results. Sometime the first page is OK but the rest is redundant. Plus the result is always different then when opened in a DWG viewer. Is there anyway to convert a file into a PDF so it looks like opened in a viewer? Does it has to contain all the additional strange pages?

Thanks in advance for your help,
Mariusz

As a sample, let’s take a look at “house design.dxf”. I’m attaching a screenshot from a viewer and the output PDF. How can I make the PDF output looking the same?


Thanks,
Mariusz
Hi Mariusz,

Thank you for your inquiry.

We have investigated the issue at our end. Initial investigation shows that the issue persists. The issues has been logged into our system. The details of the logged issues are given below. Our product team will further look into it. We will update you with the progress via this forum thread.

CADJAVA-34: DXF to PDF conversion is producing very small view in resultant PDF
CADJAVA-35: DXF to PDF conversion is producing empty pages


Thank you,


what about the other issues?

1. architectural_-annotation_scaling_and_multileaders.dwg - doesn’t render at all
2. torso_uniform.dxf - doesn’t render, produces empty PDF
3. gekko.dxf - image is splitted into several PDF pages
4. laruna50k.dxf - PDF contains only two empty pages
5. Mc Cormik-D3262.DXF - image is splitted into several PDF pages
6. visualization-_sun_and_sky_demo - PDF almost empty with strange page size
7. drilling_machine.dxf - completely wrong PDF output

There are just couple of files that actually are rendered correctly.
Additionally I’m attaching PNG output of one of the files. Every single PNG rendered contains an empty black space as on the attached image.


Thanks in advance for solving those issue.
Kind Regards,
Mariusz Pala
Hi Mariusz,

We have investigated the issues. It was found that file “architectural_-_annotation_scaling_and_multileaders.dwg” is of version DWG AutoCAD 2007, AutoCAD 2008, AutoCAD 2009. These versions of DWG are not supported. Furthermore the issues related to generating empty PDFs and splitting image into multiple pages have been logged into our system. Details are given below:

CADJAVA-36: Converting DXF to PDF is showing empty pages in PDF
CADJAVA-37: Converting DXF to PDF is splitting image on multiple pages in PDF

We have also tested the DXF to PNG conversion of the sample file “A_000217.dxf”. We are unable to reproduce the issue of black space in the resultant PNG file. Sample code and output file is attached for your reference.

CODE:

com.aspose.imaging.Image objimg = com.aspose.imaging.Image.load("A_000217.dxf");
//Create an instance of CadRasterizationOptions
com.aspose.imaging.imageoptions.CadRasterizationOptions rasterizationOptions =
new com.aspose.imaging.imageoptions.CadRasterizationOptions();
//Set page width & height
int squareSize=1200;
rasterizationOptions.setPageWidth(squareSize);
rasterizationOptions.setPageHeight(squareSize);
//Create an instance of PngOptions for the resultant image
ImageOptionsBase options = new PngOptions();
//Set rasterization options
options.setVectorRasterizationOptions(rasterizationOptions);
//Save resultant image
objimg.save("A_000217_dxf.png", options);

Thank you. What about files 6 & 7?


6. visualization_-_sun_and_sky_demo - PDF almost empty with strange page size
7. drilling_machine.dxf - completely wrong PDF output

Concerning the PNG conversion, we want to retain the image size and thus we user the code below:

com.aspose.cad.Image image = com.aspose.cad.Image.load(path);

// Create an instance of CadRasterizationOptions and set its various properties
com.aspose.cad.imageoptions.CadRasterizationOptions rasterizationOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions();
//rasterizationOptions.setTypeOfEntities(TypeOfEntities.Entities3D);
//rasterizationOptions.setContentAsBitmap(true);
rasterizationOptions.setAutomaticLayoutsScaling(true);

rasterizationOptions.setPageWidth(image.getWidth());
rasterizationOptions.setPageHeight(image.getHeight());

// Create an instance of PdfOptions
com.aspose.cad.imageoptions.PdfOptions pdfOptions = new com.aspose.cad.imageoptions.PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
//System.out.println("Converting: " + file.getName());

// Create an instance of PdfOptions
com.aspose.cad.imageoptions.PngOptions pngOptions = new com.aspose.cad.imageoptions.PngOptions();
// Set the VectorRasterizationOptions property
pngOptions.setVectorRasterizationOptions(rasterizationOptions);
//System.out.println("Converting: " + file.getName());

image.save(pdfPath, pngOptions);
Hi Mariusz,

For point #7, we have investigated the issue and found that the issue persists. The issue has been logged into our system with ID CADJAVA-38. Our product team will further look into it. For point #6, we have covered it under ticket ID CADJAVA-34.

For conversion to PNG issue, we have used the code snippet supplied by you but are unable to reproduce it. Following is the code sample and output file is also attached for reference.

CODE:

com.aspose.cad.Image objimg = com.aspose.cad.Image.load("A_000217.dxf");
//Create an instance of CadRasterizationOptions
com.aspose.cad.imageoptions.CadRasterizationOptions rasterizationOptions =
new com.aspose.cad.imageoptions.CadRasterizationOptions();
rasterizationOptions.setPageWidth(objimg.getWidth());
rasterizationOptions.setPageHeight(objimg.getHeight());
//Create an instance of PngOptions for the resultant image
com.aspose.cad.ImageOptionsBase options = new com.aspose.cad.imageoptions.PngOptions();
//Set rasterization options
options.setVectorRasterizationOptions(rasterizationOptions);

//Save resultant image
objimg.save("A_000217_dxf.png", options);

I used the code below for PNG rendering, all images rendered have incorrect size and some additional black background, check the files and output here:


Additionally, e.g. file “cnc machine” is incorrectly rendered as the source image contains some 3D image and the output is just some rubbish.

Basically I don’t see a single PNG correctly rendered from the source file.

https://www.dropbox.com/sh/gabb62qrq8aueli/AADOvjkpaOqW_bfmvR3zFkHea?dl=0

// Create an instance of CadRasterizationOptions and set its various properties
com.aspose.cad.imageoptions.CadRasterizationOptions rasterizationOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions();
//rasterizationOptions.setTypeOfEntities(TypeOfEntities.Entities3D);
//rasterizationOptions.setContentAsBitmap(true);
//rasterizationOptions.setAutomaticLayoutsScaling(true);

rasterizationOptions.setPageWidth(image.getWidth());
rasterizationOptions.setPageHeight(image.getHeight());

// Create an instance of PdfOptions
com.aspose.cad.imageoptions.PdfOptions pdfOptions = new com.aspose.cad.imageoptions.PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
//System.out.println("Converting: " + file.getName());

// Create an instance of PdfOptions
com.aspose.cad.imageoptions.PngOptions pngOptions = new com.aspose.cad.imageoptions.PngOptions();
// Set the VectorRasterizationOptions property
pngOptions.setVectorRasterizationOptions(rasterizationOptions);
//System.out.println("Converting: " + file.getName());

image.save(pdfPath, pngOptions);
Hi Mariusz,

Thank you for your inquiry.

We have investigated the issue. It was found that the issue persists. The issue has been logged into our system with ID CADJAVA-39. Our product team will further look into it. We will update you with the progress via this forum thread.

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

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