Persits Software, Inc. Web Site
 Navigator:  Home |  Object Reference |  PdfPreview
PdfRect PdfParam
  PdfPreview Object
Introduced in Version 2.6, the PdfPreview object implements the PDF-to-image conversion functionality. An instance of the PdfPreview object is created via the PdfPage.ToImage method and represents the rasterized image of the page from which it is created. The image in PNG format can be saved to disk, memory or an HTTP stream via the methods Save, SaveToMemory and SaveHttp, respectively. This object can also be used for image extraction and automatic printing.

For more information, see Chapter 17 - PDF to Image Conversion of the User Manual.

Properties Methods


int Height (Read-only)

Returns the pixel height of the resultant image.

string Log (Read-only)

Returns a double-CRLF separated list of errors encountered during the PDF-to-image conversion process. The parameter Debug=True needs to be used in the ToImage method to enable error logging.

TextItems As PdfTextItems (Read-only)

Returns a collection of PdfRect objects each representing a text fragment obtained during structured text extraction. This collection is only populated if the PdfPage.ToImage method is called with a non-zero ExtractText parameter. This property was introduced in Version 2.8.

For more information, see Section 17.7 - Structured Text Extraction.

int Width (Read-only)

Returns the pixel width of the resultant image.


void ExtractImage ( int Index )
Extracts an image specified via 1-based Index from the PDF page from which the current PdfPreview object was created. Returns a new instance of the PdfPreview object representing the extracted image. Returns Nothing (null) if Index exceeds the number of images on the page.

For more information, see Section 17.5 - Image Extraction.

string Save ( string Path )
string Save ( string Path, bool Overwrite )
Saves the resultant image to disk, returns the file name under which the image was saved (without a path). The image format is specified by the file extension (last 3 letters) of Path. The following extensions are currently supported: "png", "gif", "jpg", "bmp" and "tif". If the extension cannot be recognized, the image is saved in PNG format by default.

Path specifies the full file path.

Overwrite is an optional argument specifying whether a file under the same name should be overwritten (if set to True or omitted) or a unique filename should be generated to avoid overwriting an existing file (if set to False). True by default.

Returns the filename (without the path) under which this image ends up being saved.

void SaveHttp ( string DispHeader )
void SaveHttp ( string DispHeader, ImageFormat Format )
Sends the image to an HTTP stream. SaveHttp can only be called in an ASP.NET environment as it internally uses ASP.NET's Response.BinaryWrite method.

DispHeader specifies the Content-Disposition header to be included in the HTTP stream. This header carries the file name information to be presented to the user when the file is saved to disk on the client machine. This argument has to be in one of the following two formats:



"attachment; filename=somename.png"

The latter prompts the user to save the file to disk instead of opening it in-place in the browser.

Format is an instance of the .NET System.Drawing.Imaging.Format class and specifies the format the image is to be saved in. If this parameter is not specified, the image is saved in PNG format.

byte [] SaveToMemory ()
byte [] SaveToMemory (ImageFormat Format )
Saves the image to a memory array. This method is useful for saving the images in the database as blobs.

Format is an instance of the .NET System.Drawing.Imaging.Format class and specifies the format the image is to be saved in. If this parameter is not specified, the image is saved in PNG format.

void SendToPrinter ( string Printer, object Param ) As Boolean
Sends the underlying page image to a printer.

Printer is a network printer name, such as "\\\HP LaserJet 6P". If Printer is set null (Nothing), the default printer name for the current machine is used.

Param is a PdfParam object or parameter string. The following optional parameters are supported:

  • Stretch - if set to True, the image is stretched to cover the entire print area. False by default.

  • ScaleX, ScaleY - a number greater than 0. Specifies the scaling factor when Stretch is set to True. A value greater than 1 increases the image, less than 1 decreases it. Ignored when Stretch is False.
For more information, see
Section 17.6 - Printing.

PdfRect PdfParam

Newsletter Signup

Other Products
  This site is owned and maintained by Persits Software, Inc. Copyright © 2003 - 2014. All Rights Reserved.