Gnostice PDFOne
Pro. Ed. v5.4


com.gnostice.pdfone
Interface PdfSaveAsImageHandler

All Known Implementing Classes:
PdfSaveAsImageAdapter

public interface PdfSaveAsImageHandler

This interface defines a run-time event that is generated when an overloaded PdfDocument.saveAsImage() method tries to save the image of a page. User classes can implement this interface to track or control how images are saved.

import java.io.IOException;

import com.gnostice.pdfone.PDFOne;
import com.gnostice.pdfone.PdfDocument;
import com.gnostice.pdfone.PdfException;
import com.gnostice.pdfone.PdfReader;
import com.gnostice.pdfone.PdfSaveAsImageHandler;

public class PdfSaveAsImageHandler_Example implements
    PdfSaveAsImageHandler
{
    static
    {
        PDFOne.activate("T95VZE:W8HBPVA:74VQ8QV:LO4V8",
            "9B1HRZAP:X5853ERNE:5EREMEGRQ:TX1R10");
    }

    public static void main(String args[]) throws IOException,
        PdfException
    {
        // Read document passed in command line
        PdfReader reader = PdfReader.fileReader(args[0]);
        PdfDocument doc1 = new PdfDocument(reader);

        // Specify object implementing onSaveAsImage() event 
        doc1.setSaveAsImageHandler(
            new PdfSaveAsImageHandler_Example());

        // Save pages 1 and 2 of the read document as images
        doc1.saveAsImage("jpg", "1,2", "image_of_page_#", ".");

        reader.dispose();
    }

    // Append page number to the names of the images 
    public void onSaveAsImage(PdfDocument pdfDocument, int pageNum,
        StringBuffer imageName, StringBuffer outputPath)
    {
        imageName = imageName.append(String.valueOf(pageNum));
    }

}


Method Summary
 void onSaveAsImage(PdfDocument pdfDocument, int pageNum, StringBuffer imageName, StringBuffer outputPath)
          Called by an overloaded PdfDocument.saveAsImage() method when it tries to save an image of a page or several pages.
 

Method Detail

onSaveAsImage

void onSaveAsImage(PdfDocument pdfDocument,
                   int pageNum,
                   StringBuffer imageName,
                   StringBuffer outputPath)
Called by an overloaded PdfDocument.saveAsImage() method when it tries to save an image of a page or several pages. User classes implementing this interface can handle this event to make further changes to imageName and outputPath at run time.

Parameters:
pdfDocument - document from which image is saved
pageNum - number of the page whose image is saved
imageName - name of the image
outputPath - path of location where the image is saved

Gnostice PDFOne
Pro. Ed. v5.4

To contact our support team, send an e-mail to support@gnostice.com.
 
© 2015 Gnostice Information Technologies Private Limited. All rights reserved.
www.gnostice.com