当我尝试将pdf转换为图像时,我收到了这个日志:
Mar 12, 2014 1:49:49 PM org.apache.pdfbox.pdmodel.font.PDCIDFontType2Font getawtFont
INFO: Can't read the embedded font IPGDLH+OpenSans
Mar 12, 2014 1:49:49 PM org.apache.pdfbox.pdmodel.font.PDType0Font getawtFont
INFO: Using font SansSerif.plain instead of IPGDLH+OpenSans
Mar 12, 2014 1:49:49 PM org.apache.pdfbox.pdmodel.font.PDCIDFontType2Font getawtFont
INFO: Can't read the embedded font IPGDLH+OpenSans
Mar 12, 2014 1:49:49 PM org.apache.pdfbox.pdmodel.font.PDType0Font getawtFont
INFO: Using font SansSerif.plain instead of IPGDLH+OpenSans
Mar 12, 2014 1:49:49 PM org.apache.pdfbox.pdmodel.font.PDCIDFontType2Font getawtFont
INFO: Can't read the embedded font IPGDLH+OpenSans
Mar 12, 2014 1:49:49 PM org.apache.pdfbox.pdmodel.font.PDType0Font getawtFont
INFO: Using font SansSerif.plain instead of IPGDLH+OpenSans
由于此日志,我无法将pdf正确转换为图像。
我的代码是:
val file = new File(path + name)
val doc = PDDocument.load(new FileInputStream(file));
val pages = doc.getDocumentCatalog().getAllPages()
val listOfImage= for (i <- 0 until pages.size()) yield {
val page = pages.get(i)
val image = page.asInstanceOf[PDPage].convertToImage()
image
}
我正在使用这些库:
"org.apache.pdfbox" % "pdfbox" % "1.8.2",
"org.apache.pdfbox" % "fontbox" % "1.8.2"
如果我做错了,请告诉我。为此提供一些可行的解决方案。