Hi
All our documents are currently working just fine. Our font directory contains (nearly) only those fonts that we actually use in the mailmerge templates:
arial.ttf,
arialbd.ttf
arialbi.ttf
ariali.ttf
ARIALN.TTF
ARIALNB.TTF
ARIALNBI.TTF
ARIALNI.TTF
cour.ttf
symbol.ttf
symbole.fon
verdana.ttf
verdanab.ttf
verdanai.ttf
verdanaz.ttf
As requested, these fonts are attached to this topic (fonts.zip).
The problem is, that if we suddenly use a new font (or font variant?) in our document, possibly by mistake (just a single space in the wrong styling is enough), then Aspose does NOT do font substitution, but instead fails hard with the very unhelpfull IllegalStateException that does not tell us which font is missing.
I would be very happy if I could somehow configure Aspose to actually do the font-substitution you mention above, and if I could somehow catch and print out exactly which font it is looking for so I can either provide this font if it was on purpose, or find and remove the offending style from my template document.
I hope this explains the issue a little better.
By the way, we save our PDF with the following method:
private void saveToPDF(Document doc, File tmpFile) throws Exception {
PdfOptions options = new PdfOptions();
options.setJpegQuality(100);
options.setHeadingsOutlineLevels(0);
options.setExpandedOutlineLevels(0);
options.setTrueTypeFontsFolder(getClass().getResource("/Fonts").getFile());
doc.saveToPdf(0, doc.getPageCount(), tmpFile.getAbsolutePath(), options);
}
And the font-folder assignment works as expected, as I have numerous times had the problem with missing fonts, and made it go away by adding the new font to this directory. E.g. when we switched all our documents from Verdana to Arial.
Regards Jan
I just thought I should maybe add the generated stacktrace:
java.lang.IllegalStateException: Cannot find any fonts installed on the system.
at asposewobfuscated.qx.A (TTFontFiler.java:81)
at asposewobfuscated.oa.hc (PalFont.java:24)
at com.aspose.words.xb.Hd (SpanPr.java:231)
at com.aspose.words.sf.rr (Span.java:730)
at com.aspose.words.sf.getWidth (Span.java:593)
at com.aspose.words.zq.Jy (LineBuilder.java:88)
at com.aspose.words.zq.Jx (LineBuilder.java:30)
at com.aspose.words.bz.V (LinePart.java:281)
at com.aspose.words.k.c (ColumnBuilder.java:481)
at com.aspose.words.k.a (ColumnBuilder.java:163)
at com.aspose.words.k.a (ColumnBuilder.java:97)
at com.aspose.words.mw.a (PageBuilder.java:119)
at com.aspose.words.mw.a (PageBuilder.java:60)
at com.aspose.words.aji.b (SectionReflower.java:40)
at com.aspose.words.il.nG (MainTextSectionLayout.java:757)
at com.aspose.words.ql.nG (StoryLayoutBase.java:88)
at com.aspose.words.mu.nG (PageLayoutModel.java:124)
at com.aspose.words.yz.a (LayoutDocument.java:33)
at com.aspose.words.Document.updatePageLayout (Document.java:1637)
at com.aspose.words.Document.Iu (Document.java:1590)
at com.aspose.words.Document.getPageCount (Document.java:1618)
at dk.letpension.raadgivning.print.aspose.AsposeDocumentGenerator.saveToPDF
(AsposeDocumentGenerator.java:60)
at dk.letpension.raadgivning.print.aspose.AsposeDocumentGenerator.generatePDF
(AsposeDocumentGenerator.java:69)