Failed add eps image to pdf using Java 'because "<local2>" is null'

Hey guys, I’m trying to follow instruction EPS to PDF Converter using Java | Aspose.PDF to get eps document type, and add this eps file into our pdf file template. By using below code:

Document document = new Document();
Page page = document.getPages().add();

// ... add other text and images

// Add eps file to pdf by configuration
PsLoadOptions psLoadOptions = new PsLoadOptions();
Document epsDoc = new Document("<epsAbsolutePath>/football_logo.eps", psLoadOptions);
PdfPageStamp stamp = new PdfPageStamp(epsDoc.getPages().get_Item(1));
stamp.setHeight(150);
stamp.setWidth(150);
stamp.setXIndent(50);
stamp.setYIndent(50);
page.addStamp(stamp);

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
document.save(outputStream, SaveFormat.Pdf);
return outputStream.toByteArray();

However, i’m not able to get same result, and when hitting this line:
Document epsDoc = new Document(“/football_logo.eps”, psLoadOptions);
app will show below exception:

java.lang.NullPointerException: Cannot invoke “java.awt.Font.getFontName()” because “” is null
at com.aspose.pdf.internal.eps.postscript.l0n.lf(Unknown Source)
at com.aspose.pdf.internal.eps.postscript.FontOperator.findFont(Unknown Source)
at com.aspose.pdf.internal.eps.postscript.ResourceOperator.lI(Unknown Source)
at com.aspose.pdf.internal.eps.postscript.ResourceStatus.execute(Unknown Source)
at com.aspose.pdf.internal.eps.postscript.l3f.checkAndExecute(Unknown Source)
at com.aspose.pdf.internal.eps.postscript.l5j.lf(Unknown Source)
at com.aspose.pdf.internal.eps.postscript.l5j.lf(Unknown Source)
at com.aspose.pdf.internal.eps.postscript.l5j.lj(Unknown Source)
at com.aspose.pdf.internal.l16v.l0t.lj(Unknown Source)
at com.aspose.pdf.internal.l16v.l0t.lI(Unknown Source)
at com.aspose.pdf.internal.l16v.l0t.lI(Unknown Source)
at com.aspose.pdf.internal.l16v.l0t.lI(Unknown Source)
at com.aspose.pdf.l6h.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.(Unknown Source)
at com.aspose.pdf.Document.(Unknown Source)
at com.optum.idcard.library.print.image.pdfRenders.PdfImagePrinter.render(PdfImagePrinter.java:62)

We are using aspose-pdf library by using gradle dependency:
implementation(“com.aspose:aspose-pdf:24.7”)

And repository
maven { url = URI(“Aspose Repository Browser /java/repo/”) }

Attached is my sample eps file:

football_logo.eps.zip (33.3 KB)

@shadowonder

Would you please make sure that all Windows Fonts are installed in the system where you are trying the conversion? In case issue still persists, would you please share what JDK version are you using?

Hi @asad.ali

Thank you for your response, I’m using macos. My jdk version 17 and all windows font is already installed, but issue still same.

image.png (87.4 KB)

@shadowonder

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-44231

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.