Error displaying some PDFs with OpenViewerFX

656 Views Asked by At

I am using OpenViewerFX (JPedal) to display PDF files in a JavaFX application. Some files are displayed well, others only show not printable characters (in documents created by myself and also documents from other people). See for example this one:

Display error

This is my code:

private final PdfDecoderFX pdf = new PdfDecoderFX();
private Group group;

@Override
public void start(Stage stage) {

    BorderPane bp = new BorderPane();
    Scene scene = new Scene(bp, 400, 400);
    stage.setScene(scene);
    stage.show();

    group = new Group();
    group.getChildren().add(pdf);

    bp.setCenter(group);


    Platform.runLater(() -> {
        try {
            pdf.openPdfFile("D:\\Dokument1.pdf");
            decodePage();
        } catch (PdfException e) {
            e.printStackTrace();
            System.out.println(e.getMessage());
        }
    });
}

private void decodePage() {

    try {
        pdf.setPageParameters(2.0f, 0);
        pdf.decodePage(1);
        pdf.waitForDecodingToFinish();
    } catch (final Exception e) {
        e.printStackTrace();
        System.out.println(e.getMessage());
    }
}


The PDF file was created from a Word document with Adobe PDF printer. I used the standard font and only standard characters. I tested several settings when creating the file, including

  • Compatibility "PDF 1.3" to "PDF 1.7"
  • Enable/Disable web optimization
  • Include all fonts
  • Include Open-Type fonts

but always the same result.

What could I be doing wrong?

1

There are 1 best solutions below

4
Lonzak On

Seems like a font issue to me. The debugging output helped me in the past - at least I saw some error message in there. I'm not quite sure what the correct option was but try the following:

  1. Did you try to enable jpedal logging?
//debug code
LogWriter.log_name="/yourpath/log.txt";
LogWriter.setupLogFile(true,0,"1.0","v",false);
  1. What does the org.jpedal.PdfDecoder.getPageDecodeStatus(int type)state where type is any value Defined in org.jpedal.parser.DecodeStatus

  2. We use a patched version of the ViewerFX - can you try that one?

  3. Are you sure you specified the correct path to the fonts? To add a whole directory of fonts via JVM flag set the JVM flag -Dorg.jpedal.fontdirs=dirList where dirList is a comma-separated list of possible directories.

  4. What is your OS? Windows or Linx?

  5. Did you also try the -Dorg.jpedal.inclusiveLogFilter= "memory,error"JVM option?

  6. Try to set -Dverbose=true

  7. Call GUI.debugFX=true; see here.