Free Support Forum - aspose.com

Convert IGES to PDF: What to class to use when loading image file? CadImage or Image?

When loading IGES files, in the sample code, it uses CadImage class.
But it produce exceptions.

When loading IGES files, using Image.
I encounter no problem.

Is this only for IGES files?
Because for STL, DXF, and DWG, using CadImage class has no problem.

Attached is sample IGES file.
PenAssy.zip (224.9 KB)

Below is sample code that produce the exception:

public class ExportIGEStoPDF {
 

public static void main(String[] args)
{ 
   //ExStart:ExportIGEStoPDF  
    String dataDir = Utils.getDataDir(ExportIGEStoPDF.class) + "IGESDrawings\\";
    String PLTPathToFile = dataDir + "PenAssy.igs";
    CadImage image = (CadImage)Image.load(PLTPathToFile);
  
    //Setting PDF Options
    PdfOptions pdfOptions = new PdfOptions();
    CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
    cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);
    cadRasterizationOptions.setPageHeight(1000);
    cadRasterizationOptions.setPageWidth(1000);
  
    pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions);
   
    //Saving to PDF
    image.save(dataDir+"figa2.pdf", pdfOptions);

//ExEnd:ExportIGEStoPDF
}
}

@franciss

Actually, Image is parent class for both CadImage and IgesImage classes. Therefore, you can use Image or IgesImage class for IGES files.

1 Like