Gnostice PDFOne
Pro. Ed. v5.0.0


com.gnostice.pdfone
Class PdfSaveAsImageAdapter

java.lang.Object
  extended bycom.gnostice.pdfone.PdfSaveAsImageAdapter
All Implemented Interfaces:
PdfSaveAsImageHandler

public class PdfSaveAsImageAdapter
extends Object
implements PdfSaveAsImageHandler

This class provides empty onSaveAsImage() event handlers that can be extended by user classes so as to track or control how each image is saved from a page. The events are called by an overload PdfDocument.saveAsImage() method.

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.PdfSaveAsImageAdapter;

public class PdfSaveAsImageAdapter_Example extends
    PdfSaveAsImageAdapter
{
    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 doc = new PdfDocument(reader);

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

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

        reader.dispose();
    }

    // Append page number to the names of the images 
    public void onSaveAsImage(PdfDocument pdfDocument, int pageNum,
        int[] imageWidth, int[] imageHeight,
        float[] compressionLevel, StringBuffer imageName,
        StringBuffer outputPath)
    {
        compressionLevel[0] = 0.1f; 
        imageName = imageName.append(String.valueOf(pageNum));
    }

}


Constructor Summary
PdfSaveAsImageAdapter()
           
 
Method Summary
 void onSaveAsImage(PdfDocument pdfDocument, int pageNum, int[] imageWidth, int[] imageHeight, float[] compressionLevel, StringBuffer imageName, StringBuffer outputPath)
          Called by an overloaded PdfDocument.saveAsImage() method when it tries to save an image of a page or several pages and which user classes can extend to specify compressional level and image dimensions apart from making changes to imageName and outputPath at run time.
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfSaveAsImageAdapter

public PdfSaveAsImageAdapter()
Method Detail

onSaveAsImage

public void onSaveAsImage(PdfDocument pdfDocument,
                          int pageNum,
                          StringBuffer imageName,
                          StringBuffer outputPath)
Description copied from interface: PdfSaveAsImageHandler
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.

Specified by:
onSaveAsImage in interface PdfSaveAsImageHandler
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

onSaveAsImage

public void onSaveAsImage(PdfDocument pdfDocument,
                          int pageNum,
                          int[] imageWidth,
                          int[] imageHeight,
                          float[] compressionLevel,
                          StringBuffer imageName,
                          StringBuffer outputPath)
Called by an overloaded PdfDocument.saveAsImage() method when it tries to save an image of a page or several pages and which user classes can extend to specify compressional level and image dimensions apart from making 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
imageWidth - width of the image
imageHeight - height of the image
compressionLevel - compression level of the image
imageName - name of the image
outputPath - path of location where the image is saved

Gnostice PDFOne
Pro. Ed. v5.0.0

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