We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error while converting color DWG to PDF (UseObjectColor mode)

I modified code of demo ConvertDWGFileToPDF to convert my color image from DWG to PDF

package com.aspose.cad.examples.DWGDrawings;

import com.aspose.cad.*;
import com.aspose.cad.examples.Utils.Utils;
import com.aspose.cad.imageoptions.CadRasterizationOptions;
import com.aspose.cad.imageoptions.PdfOptions;
import com.aspose.cad.fileformats.cad.CadDrawTypeMode;

import java.awt.Image;

public class ConvertDWGFileToPDF {

public static void main(String[] args) {
	// The path to the resource directory.
    String dwgFile = "ColorDemo.dwg";
	String dataDir = Utils.getDataDir(ConvertDWGFileToPDF.class) + "DWGDrawings/";

    String srcFile = dataDir + dwgFile;
	 com.aspose.cad.Image objImage = com.aspose.cad.Image.load(srcFile);

	 // Create an instance of CadRasterizationOptions and set its various properties
	CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
            // Create an instance of PdfOptions
            PdfOptions pdfOptions = new PdfOptions();
            // Export the DWG to PDF
            objImage.save(dataDir + dwgFile + ".pdf", pdfOptions);


While executing code i’ve got error:

Exception in thread “main” class com.aspose.cad.cadexceptions.ImageSaveException: Image saving failed. —> class com.aspose.cad.cadexceptions.ImageSaveException: Image export failed. Error during PDF export: index —> java.lang.RuntimeException: Error during PDF export: index

When I replace UseObjectColor to UseDrawColor the code above works fine


In order to proceed further with investigation on our end, I request you to please share the source DWG file reproducing the issue on your end.


I have observed the issue shared and a ticket with ID CADJAVA-10195 has been created to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.