我在使用PDFRender将PDF文件转为图片时,发现部分出现空白页,并且提示错误:
java.lang.NullPointerException
at com.sun.pdfview.font.TTFFont.getOutline(TTFFont.java:170)
at com.sun.pdfview.font.CIDFontType2.getOutline(CIDFontType2.java:270)
at com.sun.pdfview.font.OutlineFont.getGlyph(OutlineFont.java:130)
at com.sun.pdfview.font.PDFFont.getCachedGlyph(PDFFont.java:308)
at com.sun.pdfview.font.PDFFontEncoding.getGlyphFromCMap(PDFFontEncoding.java:155)
at com.sun.pdfview.font.PDFFontEncoding.getGlyphs(PDFFontEncoding.java:115)
at com.sun.pdfview.font.PDFFont.getGlyphs(PDFFont.java:274)
at com.sun.pdfview.PDFTextFormat.doText(PDFTextFormat.java:269)
at com.sun.pdfview.PDFParser.iterate(PDFParser.java:752)
at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)
at java.lang.Thread.run(Thread.java:745)
打开TTFFont.java:170处是内容:
protected synchronized GeneralPath getOutline(int glyphId, float width) {
GlyfTable glyf = (GlyfTable)this.font.getTable("glyf");
Glyf g = glyf.getGlyph(glyphId);
GeneralPath gp = null;
if (g instanceof GlyfSimple) {
gp = this.renderSimpleGlyph((GlyfSimple)g);
} else if (g instanceof GlyfCompound) {
gp = this.renderCompoundGlyph(glyf, (GlyfCompound)g);
} else {
gp = new GeneralPath();
}
HmtxTable hmtx = (HmtxTable)this.font.getTable("hmtx");
float advance = (float)hmtx.getAdvance(glyphId) / this.unitsPerEm;
float widthfactor = width / advance;
AffineTransform at = AffineTransform.getScaleInstance((double)(1.0F / this.unitsPerEm), (double)(1.0F / this.unitsPerEm));
at.concatenate(AffineTransform.getScaleInstance((double)widthfactor, 1.0D));
gp.transform(at);
return gp;
}
请大神指教应该怎么修改呢?