Persits Software, Inc. Web Site
 Navigator:  Home |  Object Reference |  PdfPreview
PdfRect PdfParamItem
  PdfPreview Object
Introduced in Version 2.0, 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.

For more information about the PDF-to-image conversion functionality, see Chapter 14 - PDF to Image Conversion.

Properties Methods


Height As Long (Read-only)

Returns the pixel height of the resultant PNG image.

Log As String (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 14.7 - Structured Text Extraction.

Width As Long (Read-only)

Returns the pixel width of the resultant PNG image.


Function ExtractImage (Index As Integer) As PdfPreview
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 14.5 - Image Extraction.

Function Save (Path As String, Optional Overwrite = True) As String
Saves the resultant PNG image to disk, returns the file name under which the image was saved (without a path).

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.

Sub SaveHttp (DispHeader As String)
Sends the PNG image to an HTTP stream. SaveHttp can only be called in an ASP or ASP.NET environment as it internally uses ASP'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 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.

Function SaveToMemory ( ) As Variant
Saves the image to a memory array. This method is useful for saving the images in the database as blobs.

Sub SendToPrinter (Printer As String, Optional Param As Variant )
Sends the underlying page image to a printer. Printer is a network printer name, such as "\\\HP LaserJet 6P". As of Version, if Printer is set to an empty string, 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 14.6 - Printing.

This method was introduced in Version 2.1.

PdfRect PdfParamItem

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