Giter Site home page Giter Site logo

pdfviewerfx's Introduction

PDFViewerFX

A library for displaying/viewing pdf documents inside your javaFX application

This library is actually a javaFX wrapper for Mozilla's PDF.js javascript library, but with this library you don't have to deal with any javascript code, so you can just use a java object to view pdf documents in javaFX.

How to get it?

You can download the jar file from the releases tab.

Maven

Releases are also available through JitPack:

<dependency>
    <groupId>com.github.Dansoftowner</groupId>
    <artifactId>PDFViewerFX</artifactId>
    <version>0.5</version>
</dependency>

Usage

First, you have to import the necessary class:

import com.dansoftware.pdfdisplayer.PDFDisplayer;
PDFDisplayer displayer = new PDFDisplayer();

primaryStage.setScene(new Scene(displayer.toNode())); // to create the javaFX object from the displayer, you have to use the toNode() function 
primaryStage.show();

/*
 * This method creates a FileInputStream and than wraps it into a
 * BufferedInputStream, and then read the data from it.
*/
displayer.displayPdf(new File("path/to/your/file.pdf"));

You can also load the pdf from a java.net.URL object:

/*
 * This method calls the URL.openStream() function to get the InputStream then wraps it into a
 * BufferedInputStream, and then read the data from it.
*/
displayer.displayPdf(new URL("https://www.tutorialspoint.com/jdbc/jdbc_tutorial.pdf"));

Or you can read the data from any kind of InputStream:

InputStream inputStream = getAnInputStream(); //just for representation
displayer.displayPdf(inputStream);

You can use the constructors as well:

PDFDisplayer(URL); //reads the data from the URL
PDFDisplayer(File); //reads the data from the File
PDFDisplayer(InputStream) //reads the data from the InputStream 

More operations, tutorials

If you want to deal with some other useful functions from this library, just go to the wiki page!

Screenshots

alt text

alt text

alt text

pdfviewerfx's People

Contributors

dansoftowner avatar scholzi100 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.