Search code examples
pdfjavafxpdf-viewer

Open Source PDFViewer Javafx


I want a pdf file to be displayed into my javafx application . Till now I have tried many things without luck including pdf.js html pdf viewer but I am getting below exception :

 Caused by: netscape.javascript.JSException: SyntaxError: Invalid character '\u8216'

Do anyone know any easier way of doing this that should be free and open source. Thanks.


Solution

  • I just created an app you can check out. Here. You could probably find a free application that converts PDF to HTML. This conversion was done using https://www.idrsolutions.com/online-pdf-to-html5-converter/. I personally use Acrobat Reader to convert my files and I am currently trying to implement all of the different functions I want my app to have.

    import java.io.File;
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.layout.StackPane;
    import javafx.scene.web.WebEngine;
    import javafx.scene.web.WebView;
    import javafx.stage.Stage;
    
    /**
     *
     * @author blj0011
     */
    public class PDFToHTMLExampleApp extends Application
    {
    
        @Override
        public void start(Stage primaryStage)
        {
            File file = new File("CookBook/index.html");
    
            WebView webView = new WebView();
            WebEngine webEngine = webView.getEngine();
            webEngine.load(file.toURI().toString());
    
            StackPane root = new StackPane();
            root.getChildren().add(webView);
    
            Scene scene = new Scene(root, 700, 1000);
    
            primaryStage.setTitle("Hello World!");
            primaryStage.setScene(scene);
            primaryStage.show();
        }
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args)
        {
            launch(args);
        }
    
    }
    

    The reason I chose this site for conversion over others is that they already have a zoom function and a function to handle the pages. The downfall is that they have disabled the search function. enter image description here