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

Free Support Forum - aspose.com

DWG TO PDF OutOfMemoryError

Idea have been changed -Xss512m -Xms16000m -Xmx16000m
demo (2).zip (784.1 KB)

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 java.awt.Image;

public class ConvertDWGFileToPDF {

public static void main(String[] args) {
	// The path to the resource directory.
    long s = System.currentTimeMillis();
    System.out.println();
	String dataDir = Utils.getDataDir(ConvertDWGFileToPDF.class) + "DWGDrawings/";
	//ExStart:ConvertDWGFileToPDF
            String srcFile = dataDir + "ddd.dwg";
	
	 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();
            rasterizationOptions.setBackgroundColor(Color.getWhite());
            rasterizationOptions.setPageWidth(4000);
            rasterizationOptions.setPageHeight(4000);
    rasterizationOptions.setAutomaticLayoutsScaling(true);

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

            // Export the DWG to PDF
            objImage.save(dataDir + "ddd.pdf", pdfOptions);

            //ExEnd:ConvertDWGFileToPDF

    long e = System.currentTimeMillis();

    System.out.println("Time taken: " + (e - s) + " ms");


}

}

@cuifei,
we have created CADJAVA-10612 to review this problem.

Can you give me the URL about CADJAVA-10612?

@cuifei,
reference is not useful for you, because this is our internal issue tracking URL. You may refer to it just by number here.
Additionally, we can not reproduce the issue with your parameters on your file, export is done successfully using 22.2 release version. Please, share your OS system, share release version you use, probably, you could create small demo project with this code that fails for you and we can run and explore it?

Examples.zip (7.0 MB) my OS system is window10

Sorry, I upload the wrong version!
you can run it with the right version Examples_RightVersion.zip (7.0 MB)

@cuifei,
your test project works fine for us using latest 22.2 release. Please, test it on your side.

Thanks for asking. But I have been run it with 22.2 version,yesterday. It still OOM.

@cuifei,
could you please provide more details, e.g. exception stack trace, IDEA logs (Help/Collect logs and diagnostic data). At the moment we still observe smooth export on our side. Thank you very much.