1

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?

Flat Eric
  • 7,971
  • 9
  • 36
  • 45

1 Answers1

1

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.

Lonzak
  • 9,334
  • 5
  • 57
  • 88
  • Thanks for the tips. I have not tried logging yet. I'll test it at monday when I'm back at work and give you response. – Flat Eric Jan 26 '18 at 15:37
  • I tested your suggestions and here are my results: **1.** Logging says "unknown font" for one document which does not work, but not for all **2.** Could not test because "org.jpedal.parser.DecodeStatus" does not exist (also not in any other package) **3.** Using this version did not change anything **4.** Adding the JVM flag did not help (should not be required at all, because I embedded the fonts in the PDF) **5.** Does not work on both Windows or Linux **6.** Program does not start with this option (main class memory,error could not be found or loaded) – Flat Eric Jan 29 '18 at 08:13
  • **7.** Added this option, seems to do nothing **8.** --> compiler error "the final field GUI.debugFx cannot be assigned" – Flat Eric Jan 29 '18 at 08:16
  • I tested IcePDF and it works for all tested PDF files, will switch to this. Thanks for the useful tips anyway, +1 – Flat Eric Jan 29 '18 at 08:16