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)