Error during PDF export ... <local5> is null

Example DWGs from AutoCAD produce an exception when saved to PDF with aspose-cad-22.7-jdk16.jar.

---- Code ----

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.net.URL;
import java.nio.file.Path;
import java.util.stream.Stream;

import com.aspose.cad.Image;
import com.aspose.cad.imageoptions.CadRasterizationOptions;
import com.aspose.cad.imageoptions.PdfOptions;

public class Main {
  
  private static final String DWG_URL = "https://download.autodesk.com/us/samplefiles/acad/architectural_-_annotation_scaling_and_multileaders.dwg";

  public static void main(String[] args) throws  Exception {
    
    Stream.of("java.version", "os.name").map(System::getProperty).forEach(System.out::println);
    
    System.out.println("classpath=");
    Stream.of(System.getProperty("java.class.path").split(File.pathSeparator)).map(File::new).map(File::getName).forEach(System.out::println);
    System.out.println("");
    
    Path licenseFile = Path.of("Aspose.Total.Java.lic");
    new com.aspose.cad.License().setLicense(licenseFile.toString());
    
    File dwg = new File(System.getProperty("java.io.tmpdir"), "cad.dwg");
    File pdf = new File(System.getProperty("java.io.tmpdir"),"cad.pdf");
    
    try (BufferedInputStream istream = new BufferedInputStream(new URL(DWG_URL).openStream());
        FileOutputStream fstream = new FileOutputStream(dwg)) {
      istream.transferTo(fstream);
    }
    
    Image image = Image.load(dwg.toString());
    CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
    rasterizationOptions.setPageWidth(1600);
    rasterizationOptions.setPageHeight(1600);
    PdfOptions pdfOptions = new PdfOptions();
    pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
    image.save(pdf.toString(), pdfOptions);
      
  }

}

----- Output ----

    17.0.4
    Linux
    classpath=
    main
    default
    main
    slf4j-api-1.7.36.jar
    org.apache.felix.framework-7.0.5.jar
    aspose-words-22.9-jdk17.jar
    aspose-cells-22.9.jar
    aspose-slides-22.8-jdk16.jar
    aspose-email-22.8-jdk16.jar
    aspose-diagram-22.9.jar
    aspose-cad-22.7-jdk16.jar
    aspose-imaging-22.9-jdk16.jar
    aspose-note-22.7-jdk17.jar
    animal-sniffer-annotations-1.9.jar
    jogl-all-main-2.3.2.jar
    gluegen-rt-main-2.3.2.jar
    jogl-all-2.3.2.jar
    jogl-all-2.3.2-natives-android-aarch64.jar
    jogl-all-2.3.2-natives-android-armv6.jar
    jogl-all-2.3.2-natives-linux-amd64.jar
    jogl-all-2.3.2-natives-linux-armv6.jar
    jogl-all-2.3.2-natives-linux-armv6hf.jar
    jogl-all-2.3.2-natives-linux-i586.jar
    jogl-all-2.3.2-natives-macosx-universal.jar
    jogl-all-2.3.2-natives-solaris-amd64.jar
    jogl-all-2.3.2-natives-solaris-i586.jar
    jogl-all-2.3.2-natives-windows-amd64.jar
    jogl-all-2.3.2-natives-windows-i586.jar
    gluegen-rt-2.3.2.jar
    gluegen-rt-2.3.2-natives-android-aarch64.jar
    gluegen-rt-2.3.2-natives-android-armv6.jar
    gluegen-rt-2.3.2-natives-linux-amd64.jar
    gluegen-rt-2.3.2-natives-linux-armv6.jar
    gluegen-rt-2.3.2-natives-linux-armv6hf.jar
    gluegen-rt-2.3.2-natives-linux-i586.jar
    gluegen-rt-2.3.2-natives-macosx-universal.jar
    gluegen-rt-2.3.2-natives-solaris-amd64.jar
    gluegen-rt-2.3.2-natives-solaris-i586.jar
    gluegen-rt-2.3.2-natives-windows-amd64.jar
    gluegen-rt-2.3.2-natives-windows-i586.jar

    class com.aspose.cad.internal.Exceptions.Exception: Error during PDF export: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null ---> java.lang.NullPointerException: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null
       --- End of inner exception stack trace ---
    com.aspose.cad.internal.fU.c.a(Unknown Source)
    com.aspose.cad.w.a(Unknown Source)
    com.aspose.cad.internal.b.e.invoke(Unknown Source)
    com.aspose.cad.system.Threading.j.invoke(Unknown Source)
    com.aspose.cad.system.Threading.n.run(Unknown Source)
    java.base/java.lang.Thread.run(Thread.java:833)
      at com.aspose.cad.internal.fU.c.a(Unknown Source)
      at com.aspose.cad.w.a(Unknown Source)
      at com.aspose.cad.internal.b.e.invoke(Unknown Source)
      at com.aspose.cad.system.Threading.j.invoke(Unknown Source)
      at com.aspose.cad.system.Threading.n.run(Unknown Source)
      at java.base/java.lang.Thread.run(Thread.java:833)
    Caused by: java.lang.NullPointerException: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null
      at com.aspose.cad.internal.E.k.<init>(Unknown Source)
      at com.aspose.cad.internal.E.h.j(Unknown Source)
      at com.aspose.cad.internal.E.h.i(Unknown Source)
      at com.aspose.cad.internal.E.h.a(Unknown Source)
      at com.aspose.cad.internal.E.j.a(Unknown Source)
      at com.aspose.cad.internal.fs.i.a(Unknown Source)
      at com.aspose.cad.internal.fv.i.a(Unknown Source)
      at com.aspose.cad.internal.fv.i.a(Unknown Source)
      at com.aspose.cad.internal.fv.i.a(Unknown Source)
      at com.aspose.cad.internal.fv.c.a(Unknown Source)
      at com.aspose.cad.internal.fv.c.a(Unknown Source)
      at com.aspose.cad.internal.fv.c.a(Unknown Source)
      at com.aspose.cad.internal.fl.E.a(Unknown Source)
      at com.aspose.cad.internal.fk.k.a(Unknown Source)
      at com.aspose.cad.internal.fl.h.a(Unknown Source)
      at com.aspose.cad.internal.fk.k.a(Unknown Source)
      at com.aspose.cad.internal.fk.k.a(Unknown Source)
      at com.aspose.cad.internal.gc.a.a(Unknown Source)
      ... 6 more
    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: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null ---> class com.aspose.cad.internal.Exceptions.Exception: Error during PDF export: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null ---> java.lang.NullPointerException: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null
       --- End of inner exception stack trace ---
    com.aspose.cad.internal.fU.c.a(Unknown Source)
    com.aspose.cad.w.a(Unknown Source)
    com.aspose.cad.internal.b.e.invoke(Unknown Source)
    com.aspose.cad.system.Threading.j.invoke(Unknown Source)
    com.aspose.cad.system.Threading.n.run(Unknown Source)
    java.base/java.lang.Thread.run(Thread.java:833)
       --- End of inner exception stack trace ---
    com.aspose.cad.Image.b(Unknown Source)
    com.aspose.cad.Image.saveInternal_internalized(Unknown Source)
    com.aspose.cad.Image.save(Unknown Source)
    Main.main(Main.java:41)
       --- End of inner exception stack trace ---
    com.aspose.cad.Image.saveInternal_internalized(Unknown Source)
    com.aspose.cad.Image.save(Unknown Source)
    Main.main(Main.java:41)
      at com.aspose.cad.Image.saveInternal_internalized(Unknown Source)
      at com.aspose.cad.Image.save(Unknown Source)
      at Main.main(Main.java:41)
    Caused by: class com.aspose.cad.cadexceptions.ImageSaveException: Image export failed. Error during PDF export: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null ---> class com.aspose.cad.internal.Exceptions.Exception: Error during PDF export: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null ---> java.lang.NullPointerException: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null
       --- End of inner exception stack trace ---
    com.aspose.cad.internal.fU.c.a(Unknown Source)
    com.aspose.cad.w.a(Unknown Source)
    com.aspose.cad.internal.b.e.invoke(Unknown Source)
    com.aspose.cad.system.Threading.j.invoke(Unknown Source)
    com.aspose.cad.system.Threading.n.run(Unknown Source)
    java.base/java.lang.Thread.run(Thread.java:833)
       --- End of inner exception stack trace ---
    com.aspose.cad.Image.b(Unknown Source)
    com.aspose.cad.Image.saveInternal_internalized(Unknown Source)
    com.aspose.cad.Image.save(Unknown Source)
    Main.main(Main.java:41)
      at com.aspose.cad.Image.b(Unknown Source)
      ... 3 more
    Caused by: class com.aspose.cad.internal.Exceptions.Exception: Error during PDF export: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null ---> java.lang.NullPointerException: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null
       --- End of inner exception stack trace ---
    com.aspose.cad.internal.fU.c.a(Unknown Source)
    com.aspose.cad.w.a(Unknown Source)
    com.aspose.cad.internal.b.e.invoke(Unknown Source)
    com.aspose.cad.system.Threading.j.invoke(Unknown Source)
    com.aspose.cad.system.Threading.n.run(Unknown Source)
    java.base/java.lang.Thread.run(Thread.java:833)
      at com.aspose.cad.internal.fU.c.a(Unknown Source)
      at com.aspose.cad.w.a(Unknown Source)
      at com.aspose.cad.internal.b.e.invoke(Unknown Source)
      at com.aspose.cad.system.Threading.j.invoke(Unknown Source)
      at com.aspose.cad.system.Threading.n.run(Unknown Source)
      at java.base/java.lang.Thread.run(Thread.java:833)
    Caused by: java.lang.NullPointerException: Cannot invoke "com.aspose.cad.internal.E.D.F()" because "<local5>" is null
      at com.aspose.cad.internal.E.k.<init>(Unknown Source)
      at com.aspose.cad.internal.E.h.j(Unknown Source)
      at com.aspose.cad.internal.E.h.i(Unknown Source)
      at com.aspose.cad.internal.E.h.a(Unknown Source)
      at com.aspose.cad.internal.E.j.a(Unknown Source)
      at com.aspose.cad.internal.fs.i.a(Unknown Source)
      at com.aspose.cad.internal.fv.i.a(Unknown Source)
      at com.aspose.cad.internal.fv.i.a(Unknown Source)
      at com.aspose.cad.internal.fv.i.a(Unknown Source)
      at com.aspose.cad.internal.fv.c.a(Unknown Source)
      at com.aspose.cad.internal.fv.c.a(Unknown Source)
      at com.aspose.cad.internal.fv.c.a(Unknown Source)
      at com.aspose.cad.internal.fl.E.a(Unknown Source)
      at com.aspose.cad.internal.fk.k.a(Unknown Source)
      at com.aspose.cad.internal.fl.h.a(Unknown Source)
      at com.aspose.cad.internal.fk.k.a(Unknown Source)
      at com.aspose.cad.internal.fk.k.a(Unknown Source)
      at com.aspose.cad.internal.gc.a.a(Unknown Source)
      ... 6 more

@wimix,
I downloaded this file and see no issues with it at first glance. Anyway I created CADJAVA-10797 to investigate this better.

Hi,

I still have the same problem on Ubuntu with version aspose.cad 23.1.

In preparation of this reply, I run an additional test on Windows: it works there. Seems to be a problem related to Linux.

@wimix,
Hi.
Could you please clarify whether the initial problem (your first post) was observed in Linux too?

The initial problem was observed on Linux, see output of java.version and os.name:
17.0.4
Linux

@wimix,
Thank you, I have reopened it, we will look.

Hi,

here’s my project
aspose-cad.zip (193.2 KB)

it references aspose-cad-23.1.jar

On Ubuntu 20.04, Ubuntu 22.04, Java 17.0.5, Java 17.0.6
class com.aspose.cad.cadexceptions.ImageSaveException: Image export failed. Cannot invoke "com.aspose.cad.internal.E.K.d()" because "<local8>" is null ---> java.lang.NullPointerException: Cannot invoke "com.aspose.cad.internal.E.K.d()" because "<local8>" is null

On Windows 10, Java 17.35
OK

@wimix,
thank you, I have updated the task, we will refer to your results.