Persits Software, Inc. Web Site
 Navigator:  Home |  Object Reference |  PdfDocument
PdfFont PdfDest
  PdfDocument Object: IDisposable
PdfDocument is a major object representing a new or existing PDF document. An instance of PdfDocument is creatable via PdfManager's CreateDocument and OpenDocument methods.

Properties Methods
Author
CompressedXRef
CreationDate
Creator
Encrypted
Filename
Fonts
Form
ID
ImportInfo
KeyLength
Keywords
Mac
MetaData
ModDate
OpenAction
OriginalFilename
OriginalPath
OriginalVersion
Outline
OwnerPassword
OwnerPasswordUsed
PageLayout
PageMode
Pages
Path
Permissions
Producer
SignatureInfo
Subject
Title
UserPassword
Version
AddTemplate
AppendDocument
ClearTemplates
Close
CreateAction
CreateColorSpace
CreateDest
CreateFunction
CreateGraphics
CreateGraphicsFromPage
CreateGState
CreateTable
Dispose
Encrypt
ExtractPages
ImportFromUrl
OpenImage
OpenUrl
Save
SaveHttp
SaveToMemory
SendToPrinter
SetViewerPrefs
Sign
VerifySignature

Properties


string Author (Read/Write)

Returns or specifies the document's author (usually the name of the person who created the document).

bool CompressedXRef (Read/Write)

Returns or specifies whether the current document uses a compressed cross-reference table. Modifying this property is generally not recommended.

DateTime CreationDate (Read/Write)

Returns or specifies the date/time the document was created.

string Creator (Read/Write)

Returns or specifies the document's creator. If the document was converted from to PDF from another format, this property returns the name of the application that created the original document.

bool Encrypted (Read-only)

Returns True is the document is encrypted.

string Filename (Read-only)

Returns the filename (without a path) under which this document was saved via the Save method. This property is particularly useful when the Save method is called with the Overwrite option set to False and the actual filename may differ from the desired filename passed to the Save method. If the document was saved using SaveToMemory or SaveHttp, this property returns an empty string.

PdfFonts Fonts (Read-only)

Returns the PdfFonts collection which enables you to obtain a PdfFont object to be passed to text-drawing methods such as PdfCanvas.DrawText. For more information, see Chapter 6 - Text and Fonts.

PdfForm Form (Read-only)

Returns the PdfForm collection of PdfAnnot objects representing interactive form fields placed on this document. For more information, see Chapter 11 - Forms.

string ID (Read-only)

Returns this document's Hex-encoded ID which is usually a random 16-byte binary sequence, such as "244F19CCDF3988289B47B29585AD9A12".

PdfParam ImportInfo (Read-only)

Returns an instance of the PdfParam object populated with the Y-coordinate and page index of the lowest vertical boundary of HTML content rendered by the last successful call to ImportFromUrl. The item names are "Y" and "Page", respectively.

For more information, see Section 15.7 - Obtaining Y-Boundary.


int KeyLength (Read-only)

If this document is encrypted, returns the key length: 40 or 128 for RC4, and -128 for AES (AES is supported in AspPDF.NET 2.0+.) Returns 0 if the document is not encrypted.

string Keywords (Read/Write)

Returns or specifies keywords associated with this document.

bool Mac (Read-only)

Returns True if this is an existing document and there are indications the file contains a MacBinary header. Returns False in all other cases.

string MetaData (Read/Write)

Returns or specifies this document's XML-based metadata string. For more information, see Section 14.2 - Metadata.

DateTime ModDate (Read/Write)

Returns or specifies the date/time the document was most recently modified.

object OpenAction (Read/Write)

Specifies a PdfDest or PdfAction object to be used when the document is opened. Use this property if you need the document to fit the window in a particular way upon opening, or perform a certain action (such as execute a script). For more information about destinations and actions, see Section 10.1 - Destinations and Section 10.4 - Actions, respectively.

Usage:

objDoc.OpenAction = objDoc.Pages[1].CreateDest("Fit=true");

objDoc.OpenAction = objDoc.CreateAction("type=JavaScript", "this.print(true)" );


string OriginalFilename (Read-only)

Returns this document's original filename (without a path) if the document was opened using PdfManager.OpenDocument. If this is a new document, or if the document was opened using PdfManager.OpenDocument( byte [] ), this property returns an empty string.

string OriginalPath (Read-only)

Returns this document's full original path if the document was opened using PdfManager.OpenDocument. If this is a new document, or if the document was opened using PdfManager.OpenDocument( byte [] ), this property returns an empty string.

string OriginalVersion (Read-only)

Returns this document's original PDF version embedded in the document header (such as "1.3"). If this is a new document, this property returns an empty string.

PdfOutline Outline (Read-only)

Returns the PdfOutline collection of PdfOutlineItem objects this document's outline structure. For more information, see Section 10.2 - Outlines.

bool OwnerPassword (Read-only)

Returns True if this document is an existing one (i.e. opened via OpenDocument), encrypted and has the owner password specified. Returns False in all other cases. For more information about owner passwords, see Section 8.1 - Overview of PDF Security.

bool OwnerPasswordUsed (Read-only)

Returns True if this document is an existing one (i.e. opened via OpenDocument), encrypted, and the owner password (as opposed to the user password) was used to open it. Returns False in all other cases.

This property is useful for permission flag enforcement. For more information about owner passwords, see Section 8.1 - Overview of PDF Security.


pdfPageLayout PageLayout (Read/Write)

Returns or specifies the page layout to be used when the document is opened. This property can be set to one of the four pdfPageLayout constants defined by the AspPDF.NET component, or an integer value. Valid values are:
  • pdfSinglePage (1): display one page at a time.
  • pdfOneColumn (2): display the pages in one column.
  • pdfTwoColumnLeft (3): display the pages in two columns, with odd-numbered pages on the left.
  • pdfTwoColumnRight (4): display the pages in two columns, with odd-numbered pages on the right.
Usage:

objDoc.PageLayout = pdfPageLayout.pdfOneColumn;


pdfPageMode PageMode (Read/Write)

Returns or specifies how the document should be displayed when opened. This property can be set to one of the four pdfPageMode constants defined by the AspPDF.NET component, or an integer value. Valid values are:
  • pdfUseNone (1): neither document outline nor thumbnail images are visible.
  • pdfUseOutlines (2): document outlines are visible.
  • pdfUseThumbs (3): thumbnail images are visible.
  • pdfFullScreen (4): full-screen mode, with no menu bar, window controls or any other window visible.
Usage:

objDoc.PageMode = pdfPageMode.pdfUseOutlines;


PdfPages Pages (Read-only)

Returns the PdfPages collection of PdfPage objects representing pages in the document. PdfPages is used to access, add and remove individual pages.

string Path (Read-only)

Returns the full path under which this document was saved via the Save method. If the document was saved using SaveToMemory or SaveHttp, this property returns an empty string.

int Permissions (Read/Write)

If this document is encrypted, returns permission flags associated with this document. If the document is not encrypted, returns 0.

For the detailed description of the PDF permission flags, see Section 8.1.2 - Permission Flags.


string Producer (Read/Write)

Returns or specifies the document's producer (usually the name of the application that generated this PDF file). When a new document is created, AspPDF sets this property to "Persits Software AspPDF for .NET - www.persits.com" by default.

string SignatureInfo (Read-only)

Returns three comma-separated properties of a digital signature: Hex-encoded SHA hash value, signature location within the PDF file, and signature placeholder's size.

For example: B7F2211A4D83D624B2C9DF7277C222BA3931E4C8,135676,5000

This property is populated during pre-signing, when the Sign method is called with the first argument set to null, and the pre-signed document is saved to disk. Pre-signing is the first step of a three-step process to perform client-side signing of server-side PDFs. For more information, see Section 8.4 - Client-Side Signing of Server-Side PDFs.

This property was introduced in Version 3.4.


string Subject (Read/Write)

Returns or specifies the document's subject.

string Title (Read/Write)

Returns or specifies the document's title.

bool UserPassword (Read-only)

Returns True if this document is an existing one (i.e. opened via OpenDocument), encrypted and has the user password specified. Returns False in all other cases. For more information about user passwords, see Section 8.1 - Overview of PDF Security.

string Version (Read/Write)

Specifies the PDF version to be embedded in the document header when the document is saved. "1.3" by default.

Methods

void AddTemplate (PdfGraphics Graph)
void AddTemplate (PdfGraphics Graph, object Param)
Associates a template graphics with this document. If one or more templates are associated with the document, the applicable templates are automatically drawn on newly added pages to serve as the background for these pages. This method is useful when new content needs to be drawn on top of a template (as opposed to a blank page) and the number of pages to be added is not known in advance, such as when calling the ImportFromUrl method. All existing templates can be cleared via the ClearTemplates method.

Graph is an instance of the PdfGraphics object representing the template graphics. It can be newly created or based on the page of another document.

Param is a PdfParam object or parameter string specifying which pages, by index, this template is applicable to as well as the position and scaling of the template on the page. The following parameters are supported (all optional):

  • From - To, From1 - To1, ..., FromN - ToN - specify 1-based ranges of pages that this template is to be applied to. By default, From is 1 and To is infinity.
  • Exclude - if set to 1, all odd pages are excluded; if set to 2, all even pages are excluded; if set to any other number or omitted, no pages are excluded. 0 by default.
  • X, Y - the coordinates of the lower-left corner of the template on the page. (0, 0) by default.
  • ScaleX, ScaleY, Angle - scaling and rotation parameters. (1, 1) and 0 by default.

For more information, see Section 15.8 - Templates. This method was introduced in Version 3.2.


void AppendDocument ( PdfDocument Document )
Appends (stitches) an existing PDF document to the current one. Document must be an instance of the PdfDocument object created via OpenDocument, but not CreateDocument. One or more documents can be stitched to this document by calling the AppendDocument method multiple times.

If Document is secure, it must have been opened with the owner password, not the user password, otherwise this method throws an error exception.

For more information on document stitching, see Section 12.2 - Document Stitching.


void ClearTemplates ()
Clears all templates added via the AddTemplate method. This method was introduced in Version 3.2.

void Close ( )
Closes the underlying PDF file if this document object is based on an existing PDF, i.e. opened via the OpenDocument method. Has no effect if this is a new document.

A PDF file opened via OpenDocument always gets closed automatically when the corresponding PdfDocument object is destroyed. However, under .NET garbage collection, the actual object destruction may be deferred thus leaving the PDF file opened and locked indefinitely. The Close method enables you to close the file explicitly when your application needs it.


PdfAction CreateAction ( object Param, string Value )
Creates and returns an instance of the PdfAction object representing an action.

Param is a PdfParam object or parameter string specifying the action type and other type-specific parameters.

Value has different meanings depending on the action type and may be ignored altogether by some action types.

For the detailed description of the CreateAction method and its parameters, see Section 10.4 - Actions.


PdfColorSpace CreateColorSpace (string Name)
PdfColorSpace CreateColorSpace (string Name, object Param)
Creates and returns an instance of the PdfColorSpace object representing a color space.

Name is the name of the color space, such as "DeviceRGB".

Param is a PdfParam object or parameter string specifying various parameters. The list of parameters is too extensive to be shown here.

For the detailed description of the CreateColorSpace method and its parameters, see Section 16.1 - PdfColorSpace Object.

This method was introduced by version 2.3.


PdfDest CreateDest ( PdfPage Page, object Param )
Creates and returns an instance of the PdfDest object representing a destination. This method is redundant. It is recommended that the method Page.CreateDest be used instead.

Page is a PdfPage object the destination is associated with.

Param is a PdfParam object or parameter string specifying various parameters of the destination.

For the detailed description of the CreateDest method and its parameters, see Section 10.1 - Destinations.


PdfFunction CreateFunction ( object Param )
Creates and returns an instance of the PdfFunction object representing a transformation function. Functions are used in conjunction with some color spaces.

Param is a PdfParam object or parameter string specifying various parameters. The list of parameters is too extensive to be shown here.

For the detailed description of the CreateFunction method and its parameters, see Section 16.2 - PdfFunction Object.

This method was introduced by version 2.3.


PdfGraphics CreateGraphics ( object Param )
Creates and returns an instance of the PdfGraphics object representing a graphics (referred to as a Form XObject by PDF specifications).

Param is a PdfParam object or parameter string specifying various creation parameters of the graphics, including:

For more information on graphics, see Section 5.3 - PdfGraphics Objects.


PdfGraphics CreateGraphicsFromPage ( PdfDocument Document, int Index )
Creates and returns an instance of the PdfGraphics object representing the page of another document specified by Document. Index specifies the 1-based index of the page within that document to be converted to a graphics object. Document must be an existing document. This method cannot be called on itself.

This method allows the page of another document to be drawn on any page of this document at an arbitrary location with rotation and scaling applied, if necessary.

This method was introduced in Version 2.1.

For more information on creating graphics from pages, see Section 9.6 - Drawing Other Documents' Pages.


PdfGState CreateGState ( object Param )
Creates an instance of the graphics state object encapsulating multiple graphics state parameters including those related to transparency operations. Also creates a transparency group object. Both the graphics state and transparency group objects are represented by an instance of the PdfGState object. This method was introduced in Version 3.1.

Param is a PdfParam object or parameter string. Valid parameters, all optional, are as follows:

  • Group - if set to True, the returned instance of the PdfGState object represents a transparency group. If set to False or omitted, it represents a graphics state. False by default.
  • BlendMode - a number between 1 and 16 specifying the blend mode (1 - Normal, 2 - Multiply, 3 - Screen, 4 - Overlay, 5 - Darken, 6 - Lighten, 7 - ColorDodge, 8 - ColorBurn, 9 - HardLight, 10 - SoftLight, 11 - Difference, 12 - Exclusion, 13 - Hue, 14 - Saturation, 15 - Color, 16 - Luminosity). Ignored if Group is set to True.
  • Alpha, FillAlpha - numbers in the range 0.0 to 1.0 specifying the stroke and fill alpha values, respectively. 1.0 by default. Ignored if Group is set to True.
  • Overprint, FillOverprint - stroke and fill overprint Boolean flags, respectively. Ignored if Group is set to True.
  • AlphaIsShape - alpha source flag. If set to True, the soft mask and alpha are interpreted as shape value, otherwise they are interpreted as opacity values. Ignored if Group is set to True.
  • TextKnockout - text knockout flag which determines the behavior of overlapping glyphs. Ignored if Group is set to True.
  • Isolated - specifies the isolated flag for a transparency group. False by default. Ignored if Group is set to False or omitted.
  • Knockout - specifies the knockout flag for a transparency group. False by default. Ignored if Group is set to False or omitted.

For more information on graphics state and transparency group objects, see Chapter 19 - Transparency.


PdfTable CreateTable ( object Param )
Creates and returns an instance of the PdfTable object representing a table.

Param is a PdfParam object or parameter string specifying various creation parameters of the table, including:

  • Width, Height (required) - the table's initial width and height.
  • Cols, Rows (optional) - the initial number of columns and rows in the table. The table is 1x1 by default.
  • CellSpacing (optional) - the table's cell spacing which is the width of a margin separating cells from each other and the outer border. Similar to HTML's CELLSPACING attribute of the <TABLE> tag. 0 by default.
  • CellPadding (optional) - the table's cell padding which is the width of a margin separating cell contents from the cell's borders. Similar to HTML's CELLPADDING attribute of the <TABLE> tag. 0 by default.
  • Border (optional) - the width of the outer border. 0 by default (which means no border).
  • CellBorder (optional) - the width of all cell borders. 1 by default.
  • BorderColor, CellBorderColor (optional) - the color of the outer border and cell border, respectively. Black by default.
  • BgColor, CellBgColor (optional) - the color of the table background and cell background, respectively. Transparent by default.

For more information on tables in general and the CreateTable method in particular, see Chapter 7 - Tables.


void Dispose ( )
Implements the IDisposable interface. Internally calls the Close method. This method was introduced in Version 2.5.

void Encrypt ( string OwnerPwd, string UserPwd )
void Encrypt ( string OwnerPwd, string UserPwd, int KeyLength )
void Encrypt ( string OwnerPwd, string UserPwd, int KeyLength, pdfPermissions Permissions )
Encrypts a document with a key of the specified length using the specified passwords, and embeds the specified permission flags into the encrypted document. This method cannot be called on an existing document.

OwnerPwd - the owner password. Can be an empty string.

UserPwd - the user password. Can be an empty string.

KeyLength - the key length, must be either 40 or 128 for RC4, or -128 for AES. AES is supported in AspPDF.NET 2.0+. Optional, 40 by default.

Permissions - a combination of pdfPermissions flags. Assumed to be pdfPermissions.pdfFull if omitted.

For more information on PDF security and the Encrypt method, see Chapter 8 - Security.


PdfDocument ExtractPages ( object Param )
Extracts one or several pages from an existing document. Returns an instance of the PdfDocument representing the new document.

Param is a PdfParam object or parameter string specifying 1-based indices of pages to be extracted via the parameters Page1, Page2, Page3, etc.

An instance of the PdfDocument object returned by this method cannot be used for anything other than saving.

Usage:

PdfDocument objNewDoc = objDoc.ExtractPages("Page1=2; Page2=6");

For more information, see Section 9.5 - Page Extraction.


string ImportFromUrl ( string URL )
string ImportFromUrl ( string URL, object Param )
string ImportFromUrl ( string URL, object Param, string Username, string Password )
Opens an HTTP URL and converts the content of the page into PDF. Populates the current PdfDocument object with the result of the conversion. The current PdfDocument can either be an empty document created with CreateDocument, or an existing document opened via OpenDocument.

Return value: if the Debug parameter (see below) is set to True, this method returns a log of non-fatal errors. Otherwise returns an empty string.

URL can be an http or https address, such as "http://www.server.com/path/file.asp", or a physical local path such as "c:\path\file.html". It can also directly specify an HTML text string, such as "<html>some HTML code</html>".

For more information about this method, see Chapter 15 - HTML to PDF Conversion.

Param is a PdfParam object or parameter string specifying various conversion parameters (all of them optional), including:

  • PageWidth - page width, 612 (8.5") by default.
  • PageHeight - page height, 792 (11") by default.
  • Landscape - if set to True, the document's pages have landscape orientation. False (portrait orientation) by default.
  • LeftMargin, RightMargin, TopMargin, BottomMargin - page margins, 54 (0.75") by default.
  • LeftMarginNNN, RightMarginNNN, TopMarginNNN, BottomMarginNNN - page margins specified individually for page number NNN. Override the default margin settings. Pages with numbers higher than NNN inherit the new settings. The effective page width must be kept unchanged, i.e. the value PageWidth - LeftMarginNNN - RightMarginNNN (or in case of Landscape=true, PageHeight - TopMarginXXX - BottomMarginXXX) must be the same for all pages. These parameters were introduced by version 1.6.0.10.
  • CodePage - specifies the encoding of the page, similar to the View/Encoding option in a browser. This parameter, if specified, overrides the charset value specified via a <META http-equiv="Content-Type"> tag in the document's body. 1252 (US ASCII) by default.
  • StopAfter - specifies the number of pages in a resultant document after which the document creation will be aborted, with an error message added to the log (see the Debug parameter below.) 200 by default.
  • DrawBackground - if set to True, each page of the generated PDF document will display a background specified by the source HTML document's BGCOLOR or BACKGROUND attributes (or their CSS equivalents BACKGROUND-COLOR and BACKGROUND-IMAGE.) False by default, which means the background remains transparent/white regardless of the source HTML document's background settings.
  • StartPage - specifies the 1-based index of a page to begin rendering on. Applies to non-empty documents only. If the specified value is greater than the number of pages in the current document, the rendering will begin on the last page of the document. 1 by default.
  • Hyperlinks - if set to True, all hyperlinks on the page being converted will be enabled (clickable). False by default. This parameter was introduced by version 1.7.
  • Media - specifies which cascading style sheets to read depending on their MEDIA attribute. Can be a combination (sum) of the following values: 1 ("all"), 2 ("screen"), 4 ("print"), 8 ("asppdf") and 128 (all others.) 255 by default, which means the MEDIA attribute is ignored altogether. This parameter was introduced by version 1.7.
  • Scale - specifies a scaling factor at which the document is rendered. 1 by default which means 100%. A number less than 1 shrinks the document, greater than 1 expands it. This parameter was introduced by version 1.7.
  • SplitImages - by default, if the bottom part of an image cannot fit on the page, the whole image is pushed down to the next page to preserve its integrity. If this parameter is set to True, an image may be split between adjacent pages if necessary. False by default. This parameter was introduced by version 1.7.
  • Debug - if set to True, the method returns a log of non-fatal errors encountered during the HTML to PDF conversion process, such as invalid image URLs, unknown fonts, etc. False by default. This parameter should be used for debugging purposes only.
  • Timeout - if set to a positive number, specifies the timeout value (in seconds) for the Resolve, Connect, Send and Receive HTTP operations (same value for all four operations.) By default, these timeout values are 0 (infinite), 60 seconds, 30 seconds and 30 seconds, respectively. This parameter was introduced by version 1.7.
  • InvertCMYK - if set to True, inverts all CMYK images on the HTML document back to normal. False by default. This parameter was introduced in version 1.9.0.12551.
  • CheckboxSize - Specifies the display size of the checkbox and radio buttons when converting interactive HTML forms to PDF. 12 by default. This parameter was introduced in version 2.0.0.14017.

Username, Password specify authentication parameters in case the URL is protected with basic authentication. These arguments can also be used to pass the authentication cookie name (prefixed with the word "Cookie:") and cookie value when using .NET Forms authentication. This is described in detail in Section 15.2 - Authentication.

Usage:

// Create a new PDF document from a URL, use Landscape mode, enable hyperlinks
PdfDocument objDoc = objPDF.CreateDocument();
objDoc.ImportFromUrl( "http://www.server.com", "landscape=true, hyperlinks=true" );
objDoc.Save( @"c:\path\doc.pdf" );


// Create a new PDF document from a local HTML file, enable logging
PdfDocument objDoc = objPDF.CreateDocument();
string LogString = objPDF.ImportFromUrl( "c:\path\doc.htm", "debug=true" );
objDoc.Save( @"c:\path\doc.pdf" );


// Render HTML from a URL onto an existing PDF document starting with page 2
PdfDocument objDoc = objPDF.OpenDocument( @"c:\path\template.pdf" );
objDoc.ImportFromUrl( "http://www.server.com/path/file.asp", "startpage=2" );
objDoc.Save( @"c:\path\doc.pdf" );


// Use direct HTML feed. The argument string must contain "<html>"
PdfDocument objDoc = objPDF.CreateDocument();
objDoc.ImportFromUrl( "<html><table><tr><td>...</td></tr></table>" );
objDoc.Save( @"c:\path\doc.pdf" );

PdfImage OpenImage ( string Path )
PdfImage OpenImage ( string Path, object Param )
PdfImage OpenImage ( byte [ ] Blob )
PdfImage OpenImage ( byte [ ] Blob, object Param )
Opens an image from a disk file or byte array, and returns an instance of the PdfImage object representing this image. Supported image formats are BMP, GIF, JPEG and TIFF. This method returns null (Nothing) if the file being opened is a multi-image TIFF and the Index parameter exceeds the number of images in the file.

Path is a full file path to the image. Must be a physical path, not a URL.

Blob is an array of bytes containing the image.

Param is a PdfParam object or parameter string specifying optional image opening properties, including:

  • Invert (optional) - if set to True, inverts an image and displays it as a negative. This parameter is useful for displaying CMYK JPEGs. False by default.
  • Interpolate (optional) - if set to True, instructs a viewer application to perform image interpolation when rendering the image for better quality (but at the expense of performance). False by default.
  • Index (optional) - specifies the 1-based index of an image within a multi-image TIFF file. This parameter is only used when a TIFF file is being opened, and ignored by all other types of images. 1 by default.

For more information on images, see Section 5.1 - PdfImage Object.


PdfImage OpenUrl ( string URL )
PdfImage OpenUrl ( string URL, object Param )
PdfImage OpenUrl ( string URL, object Param, string Username, string Password )
Opens the specified URL or HTML string (in case URL begins with "<HTML" or "<html") and converts it into a sequence of images using the Microsoft Internet Explorer rendering engine. Returns the top image in the sequence. The other images are to be obtained via the PdfImage.NextImage property.

Param is a PdfParam object or parameter string specifying various conversion parameters (all of them optional), including:

  • AspectRatio - a pagination parameter specifying the height of all (except possibly the last) page images produced by the method indirectly, via the desired page width/height ratio value. The image height is ultimately calculated based on this value and the width of the document, whatever the latter turns out to be. If neither this parameter nor PageHeight is specified, no pagination takes place.
  • PageHeight - a pagination parameter specifying the absolute height (in pixels) of all (except possibly the last) page images produced by the method. If AspectRatio parameter is specified, this parameter is ignored. If neither this parameter nor AspectRatio is specified, no pagination takes place.
  • Hem - the maximum number of pixels each page image can be trimmed by from the bottom so that the page separators would pass through a relatively blank row of pixels to achieve cleaner pagination. If this parameter is 0, no hemming takes place. If this parameter is a negative number, the entire page is scanned for a suitable pixel row.
  • HemColor - a color (usually white) that the hemming process uses as the "base" color that all pixels in each row are compared against to find a row with the fewest pixels deviating from this base color. If this parameter is not specified, the dominant color in each row is calculated and used as the base color.
  • Hyperlinks - if set to True, populates the PdfImage.Hyperlinks collection with the coordinate and URL information of the hyperlinks depicted on this image. False by default.
  • Images - if set to True or omitted, instructs IE to load images. True by default.
  • Video - if set to True or omitted, instructs IE to load video. True by default.
  • DownloadActiveX - if set to True, instructs IE to download ActiveX controls. False by default.
  • RunActiveX - if set to True, instructs IE to run ActiveX controls. False by default.
  • Java - if set to True, instructs IE to enable Java applets. False by default.
  • Scripts - if set to True, instructs IE to enable scripts. False by default.
  • WindowWidth, WindowHeight - the dimensions of the internal window hosting the WebBrowser control. 100x100 by default. Changing this size is usually not necessary except when the HTML page being converted contains frames.
  • PageBreakColor - if specified, causes the method to create a page break along a line of pixels of the specified color. By default, a row of pixels must contain 80% of pixels of the specified color to be considered a page break line. This parameter was introduced in Version 3.0.
  • PageBreakThreshold - specifies, percentage wise, how many pixels in a row must be of a particular color for this row to be considered a page break. 0.8 (80%) by default. This parameter was introduced in Version 3.0.

Username, Password specify authentication parameters in case the URL is protected with basic authentication. These arguments can also be used to pass the authentication cookie name (prefixed with the word "Cookie:") and cookie value when using .NET Forms authentication.

This method was introduced in Version 2.9.

For more information, see Chapter 18 - IE-based HTML-to-PDF conversion.


string Save ( string Path )
string Save ( string Path, bool Overwrite )
Saves the document to disk, returns the file name under which the document 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.

For example, if a document is being saved under the name proposal.pdf with the Overwrite argument set to False, and a file with the same name already exists in the destination folder, the Save method will try the filenames proposal(1).pdf, proposal(2).pdf, etc. until a unique name is found.

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

For more information, see Section 3.1 - Hello World Application.


void SaveHttp ( string DispHeader )
void SaveHttp ( string DispHeader, string ContentType )
Sends the document to an HTTP stream. This method enables your Web-based application to send PDF documents directly to client browsers without having to save them to disk first. SaveHttp can only be called in an ASP.NET environment as it internally uses ASP.NET's HttpContext.Current.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:

"filename=filename.pdf"

or

"attachment; filename=filename.pdf"

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

ContentType specifies the value for the Content-Type header. By default, this value is "application/pdf". Using this argument is generally not recommended.

For more information on the SaveHttp method, see Section 3.2.2 - Saving to HTTP Stream.


byte [ ] SaveToMemory ( )
Saves the document to a byte array. This method is useful for saving PDFs in the database as blobs.

For more information on the SaveToMemory method, see Section 3.2.1 - Saving to Memory.


void SendToPrinter ( string Printer, object Param)
Sends the underlying document to the printer.

Printer is a local or network name of the printer, such as "Brother HL-2270DW series" or "\\192.168.3.2\HP LaserJet 6P".
Param is a PdfParam object or parameter string containing various printing parameters, including:

  • 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.
  • Duplex - if set to 1 or 2, enables duplex (double-sided) printing in the long-edge-binding and short-edge-binding modes, respectively. 0 (one-sided printing) by default.
  • From1/To1, From2/To2, ..., FromN/ToN - specify N ranges of pages to be printed. Each value must be between 1 and total page count. FromN must not exceed ToN.
  • Tray - specifies the printer tray or bin. This parameter was introduced in Version 2.9. Valid values are printer-specific and should be determined by trial and error. For many printers, they are 256 and higher.
  • Color - if set to True, enables the color printing mode. Use this parameter to print a color PDF on a color printer. This parameter was introduced in Version 3.1. False by default.
  • Copies - specifies the number of copies to be printed. 1 by default. This parameter was introduced in Version 3.2.0.30569.
  • Collate - If set to True, enables collation when multiple copies of the document are printed. False by default. This parameter was introduced in Version 3.4.0.31147.
  • PaperWidth, PaperHeight - Specify the paper width and height in tenths of a millimeter. Useful when printing on a label printer. These parameters were introduced in Version 3.4.0.31147.

    The following parameters pertain to the PDF-to-Image conversion which SendToPrinter performs internally:

  • ResolutionX, ResolutionY - control print quality. By default, the resolutions are 72 (dpi) but for better print quality, values such as 300 or even 600 should be used.
  • FastCMYK - if set to True, performs CMYK-to-RGB conversion using a simple linear formula which improves conversion speed at the expense of quality. Only makes a difference if the document contains large high-resolution CMYK images and graphics. False by default.
  • IgnoreRotate - if set to True, ignores the /Rotate attribute of the pages. This may cause a landscape-oriented page to be printed with the content rotated 90 degrees. False by default.
  • IgnoreCropBox - if set to True, ignores the /CropBox attribute of the pages and uses its /MediaBox attribute instead. This may cause the printout to include areas of the page that are normally invisible when viewed in a PDF viewer. False by default.

This method was introduced in Version 2.7.

For more information, see Section 17.6.2 - Document Printing.


void SetViewerPrefs ( object Param )
Sets various viewer preferences for the document.

Param is a PdfParam object or parameter string containing various viewer preference parameters, including:

  • HideToolbar (optional) - if set to True, hides the viewer application's tool bar.
  • HideMenubar (optional) - if set to True, hides the viewer application's menu bar.
  • HideWindowUI (optional) - if set to True, hides user interface elements in the document's window (such as scroll bars and navigation controls).
  • FitWindow (optional) - if set to True, resizes the document's window to fit the size of the first displayed page.
  • CenterWindow (optional) - if set to True, positions the document's window in the center of the screen.
  • DisplayDocTitle (optional) - if set to True, makes the window's title bar display the document title taken from the Title property of the document. Otherwise, the title bar will display the name of the PDF file containing the document.
  • NonFullScreenPageMode (optional) - the document's page mode specifying how to display the document on exiting full-screen mode. Valid values are: 1 (use none), 2 (use outlines), and 3 (use thumbs).
  • PrintScaling (optional) - controls the page scaling option in a print dialog. True by default which means the application should use the current print scaling. If set to False, the print dialog should reflect no page scaling.

PdfAnnot Sign ( X509Certificate2 SignerCert, string Name, string Reason, string Location, object Param )
Digitally signs the document, embeds the signature into the document in PKCS#7 certificate-based format. Returns an instance of the PdfAnnot object representing this signature field. Documents signed with this method can only be saved to disk, not to memory or an HTTP stream. UPDATE: As of Version 2.7, signed documents can be saved to disk and memory but not an HTTP stream.

SignerCert is an instance of the X509Certificate2 object representing the ceriticate used for signing. As of Version 3.4, this argument is optional and can be set to null. See comments below.

Name specifies the signer name.

Reason specifies a reason for signing, can be null.

Location specifies a signing location, can be null.

Param is a PdfParam object or parameter string specifying various signature creation parameters, including:

As of Version 3.4, if the Sign method is called with the SignerCert argument set to null, the PDF document is "pre-signed" -- a signature placeholder is allocated within the document, but it is filled with 0s. The signature, based on the hash value obtained from the PdfDocument.SignatureInfo property, is then generated on a user workstation, transferred back to the server and injected into the PDF being signed, thus completing the signing process. For more information, see Section 8.4 - Client-Side Signing of Server-Side PDFs.

For more information on the Sign method, see Section 8.3 - Digital Signing.


PdfSignature VerifySignature ( ) As PdfSignature
Verifies a PKCS#7 signature in the document. Can only be called on an existing document, and only on a file-based, not memory-based, document.

Returns null if the document contains no PKCS#7 signatures. Otherwise, returns an instance of the PdfSignature object encapsulating various signature properties, including validation status, etc.

For more information on signature validation, see Section 8.3.4 - Signature Validation.


PdfFont PdfDest
Search AspPDF.net

Newsletter Signup

Other Products
AspPDF
AspUpload
AspJpeg
AspEmail
AspEncrypt
AspGrid
AspUser
  This site is owned and maintained by Persits Software, Inc. Copyright © 2003 - 2014. All Rights Reserved.