小编典典
看看这些免费的pdf渲染器…
一些链接…
更新
ICEpdf是一个开源Java PDF引擎,可以在任何Java应用程序内或Web服务器上呈现,转换或提取PDF内容。
对于基本功能,您必须在类路径中包含icepdf-core.jar和icepdf-viewer.jar。根据要求,您还可以添加SVG支持。
取自iceface示例文件夹:
import org.icepdf.ri.common.SwingController;
import org.icepdf.ri.common.SwingViewBuilder;
import javax.swing.*;
/**
* The ViewerComponentExample
class is an example of how to use
* SwingController
and SwingViewBuilder
* to build a PDF viewer component. A file specified at the command line is
* opened in a JFrame which contains the viewer component.
*
* @since 2.0
*/
public class ViewerComponentExample {
public static void main(String[] args) {
// Get a file from the command line to open
String filePath = args[0];
// build a component controller
SwingController controller = new SwingController();
SwingViewBuilder factory = new SwingViewBuilder(controller);
JPanel viewerComponentPanel = factory.buildViewerPanel();
// add interactive mouse link annotation support via callback
controller.getDocumentViewController().setAnnotationCallback(
new org.icepdf.ri.common.MyAnnotationCallback(
controller.getDocumentViewController()));
JFrame applicationFrame = new JFrame();
applicationFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
applicationFrame.getContentPane().add(viewerComponentPanel);
// Now that the GUI is all in place, we can try openning a PDF
controller.openDocument(filePath);
// show the component
applicationFrame.pack();
applicationFrame.setVisible(true);
}
}
上面的代码可帮助您在回转组件上显示PDF。您可以在SWT环境中进行相同的操作(看一下SwingViewBuilder..有点困难,但是SWT的外观和感觉会如此)或使用org.eclipse.swt.awt.SWT_AWT(有点简单…但是会有摇摆+
swt的外观)…但是两种方法都可以解决您的目的。还要检查许可证文件夹中的适用许可证。
希望这会有所帮助。
2020-09-11