Pregunta

Estoy usando Java y RCP y yo estoy tratando de mostrar pdf Documento con Acrobat en mis puntos de vista. No necesito para cambiarlos. Tengo este error con este código. ¿Alguna idea de cómo resolver este problema ?. P.s .: funciona buenas mismos tiempos.

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)

Saludos, Haythem

¿Fue útil?

Solución

Tener un vistazo a estos pdf libre de render ...

Algunos enlaces ...

  1. http://www.icepdf.org/ (ahora en http://www.icesoft.org/java/projects/ICEpdf/overview.jsf - Apache 2 Open Source)

  2. http://www.jpedal.org/support_siEclipse.php ( ahora en https://www.idrsolutions.com/jpedal/ - comercial)

  3. https://java.net/projects/pdf-renderer ( todavía disponibles https://github.com/yarick123/pdf-renderer - LGPL-2.1)

Actualizar

Según http://www.icepdf.org/ ,

ICEpdf es un código abierto de Java PDF motor, que puede hacer, convertir, o el contenido del PDF dentro de cualquier extracto de Java aplicación o en un servidor Web.

Para obtener una funcionalidad básica que tiene que incluir icepdf-core.jar y icepdf-viewer.jar en su ruta de clase. Dependiendo de la exigencia también se puede añadir el soporte para SVG.

Tomado de carpeta muestra iceface:

import org.icepdf.ri.common.SwingController;
import org.icepdf.ri.common.SwingViewBuilder;

import javax.swing.*;

/**
 * The <code>ViewerComponentExample</code> class is an example of how to use
 * <code>SwingController</code> and <code>SwingViewBuilder</code>
 * 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);
    }
}

El código anterior le ayuda en la visualización de un archivo PDF en un componente de oscilación. Puede hacer lo mismo en el entorno SWT (echar un vistazo a SwingViewBuilder .. un poco difícil, pero se SWT aspecto y el tacto) o el uso org.eclipse.swt.awt.SWT_AWT (especie de fácil ... pero tendrá oscilación + SWT aspecto y el tacto) .. . pesar de que tanto el enfoque va a resolver su propósito. También puedes ver las licencias aplicables en la carpeta de licencia.

Esperamos que esto ayude.

Otros consejos

Aquí hay otro visor de PDF gratuito, pequeño y potente basado en Eclipse SWT y jPod Procesador - JPview . Tiene una fuerte representación y bajo uso de memoria.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top