public void renderText(TextRenderInfo renderInfo) { DocumentFont documentFont = renderInfo.getFont(); PdfDictionary font = documentFont.getFontDictionary(); // Check the font dictionary like in your example code if (font FULFILLS SOME CRITERIA) { // The text String text = renderInfo.getText(); // is rendered on the current page on the base line LineSegment baseline = renderInfo.getBaseline(); // using a font fulfilling the given criteria ... } }
@Override protected void checkFont(PdfWriter writer, int key, Object obj1) { BaseFont bf = (BaseFont) obj1; if (bf.getFontType() == BaseFont.FONT_TYPE_DOCUMENT) { PdfStream prs = null; PdfDictionary fontDictionary = ((DocumentFont) bf).getFontDictionary(); PdfDictionary fontDescriptor = getDirectDictionary(fontDictionary.get(PdfName.FONTDESCRIPTOR)); if (fontDescriptor != null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE)); if (prs == null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE2)); } if (prs == null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE3)); } } if (prs == null) { throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).getPostscriptFontName())); } } else { if (!bf.isEmbedded()) throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).getPostscriptFontName())); } }
@Override protected void checkFont(PdfWriter writer, int key, Object obj1) { BaseFont bf = (BaseFont) obj1; if (bf.getFontType() == BaseFont.FONT_TYPE_DOCUMENT) { PdfStream prs = null; PdfDictionary fontDictionary = ((DocumentFont) bf).getFontDictionary(); PdfDictionary fontDescriptor = getDirectDictionary(fontDictionary.get(PdfName.FONTDESCRIPTOR)); if (fontDescriptor != null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE)); if (prs == null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE2)); } if (prs == null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE3)); } } if (prs == null) { throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).getPostscriptFontName())); } } else { if (!bf.isEmbedded()) throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).getPostscriptFontName())); } }