PDF格式的图像质量不佳

时间:2013-12-17 09:20:18

标签: java swing icepdf

我使用icePdf作为pdf查看器。我有一个示例PDF文件,其中包含一个图像。当我用icePdf查看器打开它时,图像质量不是很好。图像不是很清楚。这是代码。谁能建议我如何提高icePDF中的图像质量

import javax.swing.JFrame;

import javax.swing.JPanel;

import org.icepdf.ri.common.ComponentKeyBinding;
import org.icepdf.ri.common.SwingController;
import org.icepdf.ri.common.SwingViewBuilder;
import org.icepdf.core.pobjects.fonts.*;
import org.icepdf.core.*;

public class ViewerComponentExample 
{
    public static void main(String args[]) 
    {
        String filepath = "C:/Users/vishalt/Workspaces/Eclipse 4.2 Java/htmltopdf/src/XML/output/hk.pdf";


        // build a controller
        SwingController controller = new SwingController();

        // Build a SwingViewFactory configured with the controller
        SwingViewBuilder factory = new SwingViewBuilder(controller);
        JPanel viewerComponentPanel = factory.buildViewerPanel();

        // add copy keyboard command
        ComponentKeyBinding.install(controller, viewerComponentPanel);

        // add interactive mouse link annotation support via callback
        controller.getDocumentViewController().setAnnotationCallback(
        new org.icepdf.ri.common.MyAnnotationCallback(
        controller.getDocumentViewController()));

        // Use the factory to build a JPanel that is pre-configured
        //with a complete, active Viewer UI.
        // Create a JFrame to display the panel in
        JFrame window = new JFrame("Metrics Wizard Help");
        window.getContentPane().add(viewerComponentPanel);
        window.pack();
        window.setVisible(true);
        System.getProperties().put("org.icepdf.core.scaleImages", "true"); 
        // Open a PDF document to view
         controller.openDocument(filepath);
    }


}

0 个答案:

没有答案