Java PDF 查看器
我正在使用 java 和 RCP,并且尝试在我的视图中使用 Acrobat 显示 pdf 文档。 我不需要改变它们。 我的这段代码有这个错误。知道如何解决这个问题吗? PS:同样的时间效果很好。
PDFFile pdfFile;
pdfFile = PdfFileLoader.loadPdf(file, new NullProgressMonitor());
PdfDocument pdfDocument = new OneDimensionalPdfDocument(pdfFile, new NullProgressMonitor());
pdfViewer.setPdfDocument(pdfDocument);
Error from PdfDocument pdfDocument = new OneDimensionalPdfDocument(pdfFile, new NullProgressMonitor()) : Unsupport CMap format: 6
java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Unknown Source)
at java.nio.HeapByteBuffer.getShort(Unknown Source)
at com.sun.pdfview.font.ttf.HmtxTable.setData(HmtxTable.java:79)
at com.sun.pdfview.font.ttf.TrueTypeTable.createTable(TrueTypeTable.java:113)
at com.sun.pdfview.font.ttf.TrueTypeFont.getTable(TrueTypeFont.java:106)
at com.sun.pdfview.font.TTFFont.getOutline(TTFFont.java:129)
at com.sun.pdfview.font.TTFFont.getOutline(TTFFont.java:89)
at com.sun.pdfview.font.OutlineFont.getGlyph(OutlineFont.java:118)
at com.sun.pdfview.font.PDFFont.getCachedGlyph(PDFFont.java:307)
at com.sun.pdfview.font.PDFFontEncoding.getGlyphFromEncoding(PDFFontEncoding.java:132)
at com.sun.pdfview.font.PDFFontEncoding.getGlyphs(PDFFontEncoding.java:98)
at com.sun.pdfview.font.PDFFont.getGlyphs(PDFFont.java:273)
at com.sun.pdfview.PDFTextFormat.doText(PDFTextFormat.java:283)
at com.sun.pdfview.PDFParser.iterate(PDFParser.java:742)
at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:88)
at java.lang.Thread.run(Unknown Source)
问候, 海瑟姆
I am using java and RCP and I am trying to show pdf Document with Acrobat on my views.
I don't need to change them.
I have this error with this code. Any idea how to resolve this problem?. P.s.: it works good same times.
PDFFile pdfFile;
pdfFile = PdfFileLoader.loadPdf(file, new NullProgressMonitor());
PdfDocument pdfDocument = new OneDimensionalPdfDocument(pdfFile, new NullProgressMonitor());
pdfViewer.setPdfDocument(pdfDocument);
Error from PdfDocument pdfDocument = new OneDimensionalPdfDocument(pdfFile, new NullProgressMonitor()) : Unsupport CMap format: 6
java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Unknown Source)
at java.nio.HeapByteBuffer.getShort(Unknown Source)
at com.sun.pdfview.font.ttf.HmtxTable.setData(HmtxTable.java:79)
at com.sun.pdfview.font.ttf.TrueTypeTable.createTable(TrueTypeTable.java:113)
at com.sun.pdfview.font.ttf.TrueTypeFont.getTable(TrueTypeFont.java:106)
at com.sun.pdfview.font.TTFFont.getOutline(TTFFont.java:129)
at com.sun.pdfview.font.TTFFont.getOutline(TTFFont.java:89)
at com.sun.pdfview.font.OutlineFont.getGlyph(OutlineFont.java:118)
at com.sun.pdfview.font.PDFFont.getCachedGlyph(PDFFont.java:307)
at com.sun.pdfview.font.PDFFontEncoding.getGlyphFromEncoding(PDFFontEncoding.java:132)
at com.sun.pdfview.font.PDFFontEncoding.getGlyphs(PDFFontEncoding.java:98)
at com.sun.pdfview.font.PDFFont.getGlyphs(PDFFont.java:273)
at com.sun.pdfview.PDFTextFormat.doText(PDFTextFormat.java:283)
at com.sun.pdfview.PDFParser.iterate(PDFParser.java:742)
at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:88)
at java.lang.Thread.run(Unknown Source)
Regards,
Haythem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这些免费的 pdf 渲染器...
一些链接...
http://www.icepdf。 org/(现在位于 http://www.icesoft.org /java/projects/ICEpdf/overview.jsf - Apache 2 开源)
http://www.jpedal.org/support_siEclipse.php(现在位于 https ://www.idrsolutions.com/jpedal/ - 商业)
https://java.net/projects /pdf-renderer (仍然可用 https://github.com/yarick123/pdf-renderer - LGPL-2.1)
更新
按照http://www.icepdf.org/ ,
对于基本功能,您必须在类路径中包含
icepdf-core.jar
和icepdf-viewer.jar
。根据要求,您还可以添加 SVG 支持。摘自iceface示例文件夹:
上面的代码可以帮助您在swing组件上显示PDF。您可以在 SWT 环境中执行相同的操作(看看
SwingViewBuilder
.. 有点困难,但会 SWT 外观和感觉)或使用org.eclipse.swt.awt.SWT_AWT< /code> (有点简单...但会有 swing + swt 的外观和感觉)...尽管两种方法都会解决您的目的。另请检查许可证文件夹中的适用许可证。
希望这会有所帮助。
Have a look at these free pdf renderer ...
Some links ...
http://www.icepdf.org/ (now at http://www.icesoft.org/java/projects/ICEpdf/overview.jsf - Apache 2 Open Source)
http://www.jpedal.org/support_siEclipse.php (now at https://www.idrsolutions.com/jpedal/ - commercial)
https://java.net/projects/pdf-renderer (still available https://github.com/yarick123/pdf-renderer - LGPL-2.1)
UPDATE
As per http://www.icepdf.org/ ,
For basic functionality you have to include
icepdf-core.jar
andicepdf-viewer.jar
in your class path. Depending upon the requirement you can also add the SVG support.Taken from iceface sample folder:
The above code helps you in displaying a PDF on a swing component. You can do the same in the SWT environment (have a look at
SwingViewBuilder
.. kind of hard, but will SWT look and feel ) or useorg.eclipse.swt.awt.SWT_AWT
(kind of easy... but will have swing + swt look and feel)... though both approach will solve your purpose. Also check the applicable licenses in the license folder.Hope this will help.
这是另一个基于 Eclipse SWT 和 jPod Renderer 的免费、小型且功能强大的 PDF 查看器 - JPview。它具有强大的渲染能力和低内存占用。
Here is another free, small and powerful PDF Viewer based on Eclipse SWT and jPod Renderer — JPview. It has strong rendering and low memory usage.