You are viewing limited content. For full access, please sign in.

Question

Question

How to retrieve a document image using SDK Java libraries.

SDK
asked on March 19, 2015

We are trying to use the SDK Java library com.laserfiche.repositoryaccess  class Document.

We want to get the image (all pages) from a non-electronic document, and export a file as a PDF.

This PDF will then be put a browser window for a user to look at in our ERP system. 

 

Could we get an example of how to do this please.

 

Thanks

 

Brian  

0 0

Replies

replied on March 19, 2015

The JServerAccess library which implements the classes in the com.laserfiche.repositoryaccess package does not contain any PDF creation functionality. What JServerAccess allows you to do is to download the image data for the pages in a document. You can then use a third-party PDF library such as iText or PDFBox to create the PDF. To retrieve the image data for the pages in a document you would do something similar to the following:

Session session = ...;
Document doc = Document.getByPath("\\my document", session);
PageReader pages = doc.getAllPages();
while (pages.hasNext()) {
    Page page = pages.next();
    if (page.hasImage()) {
        InputStream imageStream = page.read(PagePart.IMAGE);
        // Do what you want with the imageStream here.
        // The imageStream will give you direct access to the image data,
        // which is most likely a TIFF or JPEG image.
        imageStream.close();
    }
}

 

0 0
replied on March 20, 2015

That is what we needed to get past the error we were getting!

   

Thanks Michael

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.