Show / Hide Table of Contents

Class Prince

Class that provides the default interface to Prince, where each document conversion invokes a new Prince process.

Inheritance
System.Object
PrinceBase
Prince
Inherited Members
PrinceBase.Verbose
PrinceBase.Debug
PrinceBase.Log
PrinceBase.NoWarnCssUnknown
PrinceBase.NoWarnCssUnsupported
PrinceBase.InputType
PrinceBase.BaseUrl
PrinceBase.Iframes
PrinceBase.XInclude
PrinceBase.XmlExternalEntities
PrinceBase.NoNetwork
PrinceBase.NoRedirects
PrinceBase.AuthUser
PrinceBase.AuthPassword
PrinceBase.AuthServer
PrinceBase.AuthScheme
PrinceBase.AuthMethods
PrinceBase.NoAuthPreemptive
PrinceBase.HttpProxy
PrinceBase.HttpTimeout
PrinceBase.Cookies
PrinceBase.CookieJar
PrinceBase.SslCaCert
PrinceBase.SslCaPath
PrinceBase.SslCert
PrinceBase.SslCertType
PrinceBase.SslKey
PrinceBase.SslKeyType
PrinceBase.SslKeyPassword
PrinceBase.SslVersion
PrinceBase.Insecure
PrinceBase.NoParallelDownloads
PrinceBase.JavaScript
PrinceBase.Scripts
PrinceBase.MaxPasses
PrinceBase.StyleSheets
PrinceBase.Media
PrinceBase.NoAuthorStyle
PrinceBase.NoDefaultStyle
PrinceBase.PdfId
PrinceBase.PdfLang
PrinceBase.PdfProfile
PrinceBase.PdfOutputIntent
PrinceBase.PdfScript
PrinceBase.PdfEventScripts
PrinceBase.FileAttachments
PrinceBase.NoArtificialFonts
PrinceBase.NoEmbedFonts
PrinceBase.NoSubsetFonts
PrinceBase.ForceIdentityEncoding
PrinceBase.NoCompress
PrinceBase.NoObjectStreams
PrinceBase.ConvertColors
PrinceBase.FallbackCmykProfile
PrinceBase.TaggedPdf
PrinceBase.PdfForms
PrinceBase.PdfTitle
PrinceBase.PdfSubject
PrinceBase.PdfAuthor
PrinceBase.PdfKeywords
PrinceBase.PdfCreator
PrinceBase.Xmp
PrinceBase.Encrypt
PrinceBase.KeyBits
PrinceBase.UserPassword
PrinceBase.OwnerPassword
PrinceBase.DisallowPrint
PrinceBase.DisallowCopy
PrinceBase.AllowCopyForAccessibility
PrinceBase.DisallowAnnotate
PrinceBase.DisallowModify
PrinceBase.AllowAssembly
PrinceBase.LicenseFile
PrinceBase.LicenseKey
PrinceBase.FailDroppedContent
PrinceBase.FailMissingResources
PrinceBase.FailStrippedTransparency
PrinceBase.FailMissingGlyphs
PrinceBase.FailPdfProfileError
PrinceBase.FailPdfTagError
PrinceBase.FailInvalidLicense
PrinceBase.AddFileAttachment(String)
PrinceBase.FailSafe(Boolean)
PrinceBase.StartPrince(List<String>)
PrinceBase.GetBaseCommandLine()
PrinceBase.ReadMessages(StreamReader)
Namespace: PrinceXML.Wrapper
Assembly: PrinceXML.Wrapper.dll
Syntax
public class Prince : PrinceBase

Constructors

| Improve this Doc View Source

Prince(String, PrinceEvents)

Constructor for Prince

Declaration
public Prince(string princePath, PrinceEvents events = null)
Parameters
Type Name Description
System.String princePath

The path of the Prince executable. For example, this may be C:\Program Files\Prince\engine\bin\prince.exe on Windows.

PrinceEvents events

An implementation of PrinceEvents that will receive messages returned from Prince.

Properties

| Improve this Doc View Source

CssDpi

Changes the DPI of the "px" units in CSS.

Declaration
public int CssDpi { get; set; }
Property Value
Type Description
System.Int32

The DPI of the "px" units. Value must be greater than 0. Default value is 96 dpi.

| Improve this Doc View Source

NoLocalFiles

Disable access to local files.

Declaration
public bool NoLocalFiles { get; set; }
Property Value
Type Description
System.Boolean

true if access to local files is disabled. Default value is false.

| Improve this Doc View Source

NoSystemFonts

Disable the use of system fonts. Only fonts defined with font-face rules in CSS will be available.

Declaration
public bool NoSystemFonts { get; set; }
Property Value
Type Description
System.Boolean

true if system fonts are disabled. Default value is false.

| Improve this Doc View Source

Options

Specify additional Prince command-line options.

Declaration
public List<(string, string)> Options { get; }
Property Value
Type Description
List<System.ValueTuple<System.String, System.String>>

The command line option, comprised of a key and an optional value. Pass in a null if the value is not required.

| Improve this Doc View Source

PageMargin

Specify the page margin.

Declaration
public string PageMargin { get; set; }
Property Value
Type Description
System.String

The page margin to use (e.g. "20mm").

| Improve this Doc View Source

PageSize

Specify the page size.

Declaration
public string PageSize { get; set; }
Property Value
Type Description
System.String

The page size to use (e.g. "A4").

| Improve this Doc View Source

RasterBackground

Set the background. Can be used when rasterizing to an image format that supports transparency.

Declaration
public RasterBackground RasterBackground { get; set; }
Property Value
Type Description
RasterBackground

The raster background. Default value is RasterBackground.White.

| Improve this Doc View Source

RasterDpi

Specify the resolution of raster output.

Declaration
public int RasterDpi { get; set; }
Property Value
Type Description
System.Int32

The raster output resolution. Vlaue must be greater than 0. Default value is 96 dpi.

| Improve this Doc View Source

RasterFormat

Specify the format for the raster output.

Declaration
public RasterFormat RasterFormat { get; set; }
Property Value
Type Description
RasterFormat

The format for the raster output. Default value is RasterFormat.Auto.

| Improve this Doc View Source

RasterJpegQuality

Specify the level of JPEG compression when generating raster output in JPEG format.

Declaration
public int RasterJpegQuality { get; set; }
Property Value
Type Description
System.Int32

The level of JPEG compression. Valid range is between 0 and 100 inclusive. Default value is 92.

| Improve this Doc View Source

RasterPage

Set the page number to be rasterized.

Declaration
public int RasterPage { get; set; }
Property Value
Type Description
System.Int32

The page number to be rasterized. Value must be greater than 0. Defaults to rasterizing all pages.

| Improve this Doc View Source

RasterThreads

Set the number of threads to use for multi-threaded rasterization.

Declaration
public int RasterThreads { get; set; }
Property Value
Type Description
System.Int32

The number of threads to use. Default value is the number of cores and hyperthreads the system provides.

| Improve this Doc View Source

Remaps

Rather than retrieving documents using a URL, remap them to a local directory.

Declaration
public List<(string, string)> Remaps { get; }
Property Value
Type Description
List<System.ValueTuple<System.String, System.String>>

A tuple, where the first value is a URL, and the second is the directory to remap that URL to.

Methods

| Improve this Doc View Source

Convert(List<String>, Stream)

Convert multiple XML or HTML files to a PDF file.

Declaration
public override bool Convert(List<string> inputPaths, Stream output)
Parameters
Type Name Description
List<System.String> inputPaths

The filenames of the input XML or HTML documents.

Stream output

The output Stream to which Prince will write the PDF output.

Returns
Type Description
System.Boolean

true if a PDF file was generated successfully.

Overrides
PrinceBase.Convert(List<String>, Stream)
| Improve this Doc View Source

Convert(List<String>, String)

Convert multiple XDML or HTML files to a PDF file.

Declaration
public bool Convert(List<string> inputPaths, string outputPath)
Parameters
Type Name Description
List<System.String> inputPaths

The filenames of the input XML or HTML documents.

System.String outputPath

The filename of the output PDF file.

Returns
Type Description
System.Boolean

true if a PDF file was generated successfully.

| Improve this Doc View Source

Convert(Stream, Stream)

Convert an XML or HTML stream to a PDF file. Note that it may be helpful to specify a base URL or path from the input document using BaseUrl. This allows relative URLs and paths in the document (e.g. for images) to be resolved correctly.

Declaration
public override bool Convert(Stream input, Stream output)
Parameters
Type Name Description
Stream input

The input Stream from which Prince will read the XML or HTML document.

Stream output

The output Stream to which Prince will write the PDF output.

Returns
Type Description
System.Boolean

true if a PDF file was generated successfully.

Overrides
PrinceBase.Convert(Stream, Stream)
| Improve this Doc View Source

Convert(String, Stream)

Convert an XML or HTML file to a PDF file.

Declaration
public override bool Convert(string inputPath, Stream output)
Parameters
Type Name Description
System.String inputPath

The filename of the input XML or HTML document.

Stream output

The output Stream to which Prince will write the PDF output.

Returns
Type Description
System.Boolean

true if a PDF file was generated successfully.

Overrides
PrinceBase.Convert(String, Stream)
| Improve this Doc View Source

Convert(String, String)

Convert an XML or HTML file to a PDF file.

Declaration
public bool Convert(string inputPath, string outputPath = null)
Parameters
Type Name Description
System.String inputPath

The filename of the input XML or HTML document.

System.String outputPath

The filename of the output PDF file. If not provided, the name of the output file will be the same as the name of the input file, but with the .pdf extension.

Returns
Type Description
System.Boolean

true if a PDF file was generated successfully.

| Improve this Doc View Source

ConvertString(String, Stream)

Convert an XML or HTML string to a PDF file.

Declaration
public override bool ConvertString(string input, Stream output)
Parameters
Type Name Description
System.String input

The XML or HTML document in the form of a string.

Stream output

The output Stream to which Prince will write the PDF output.

Returns
Type Description
System.Boolean

true if a PDF file was generated successfully.

Overrides
PrinceBase.ConvertString(String, Stream)
| Improve this Doc View Source

ConvertString(String, String)

Convert an XML or HTML string to a PDF file.

Declaration
public bool ConvertString(string input, string outputPath)
Parameters
Type Name Description
System.String input

The XML or HTML document in the form of a string.

System.String outputPath

The filename of the output PDF file.

Returns
Type Description
System.Boolean

true if a PDF file was generated successfully.

| Improve this Doc View Source

Rasterize(List<String>, Stream)

Rasterize multiple XML or HTML files.

Declaration
public bool Rasterize(List<string> inputPaths, Stream output)
Parameters
Type Name Description
List<System.String> inputPaths

The filenames of the input XML or HTML documents.

Stream output

The output Stream to which Prince will write the raster output.

Returns
Type Description
System.Boolean

true if the input was successfully rasterized.

| Improve this Doc View Source

Rasterize(List<String>, String)

Rasterize multiple XML or HTML files.

Declaration
public bool Rasterize(List<string> inputPaths, string outputPath)
Parameters
Type Name Description
List<System.String> inputPaths

The filenames of the input XML or HTML documents.

System.String outputPath

A template string from which the raster files will be named (e.g. "page_%02d.png" will cause Prince to generate page_01.png, page_02.png, ..., page_10.png etc.).

Returns
Type Description
System.Boolean

true if the input was successfully rasterized.

| Improve this Doc View Source

Rasterize(Stream, Stream)

Rasterize an XML or HTML stream.

Declaration
public bool Rasterize(Stream input, Stream output)
Parameters
Type Name Description
Stream input

The input Stream from which Prince will read the XML or HTML document.

Stream output

The output Stream to which Prince will write the raster output.

Returns
Type Description
System.Boolean

true if the input was successfully rasterized.

| Improve this Doc View Source

Rasterize(String, Stream)

Rasterize an XML or HTML file.

Declaration
public bool Rasterize(string inputPath, Stream output)
Parameters
Type Name Description
System.String inputPath

The filename of the input XML or HTML document.

Stream output

The output Stream to which Prince will write the raster output.

Returns
Type Description
System.Boolean

true if the input was successfully rasterized.

| Improve this Doc View Source

Rasterize(String, String)

Rasterize an XML or HTML file.

Declaration
public bool Rasterize(string inputPath, string outputPath)
Parameters
Type Name Description
System.String inputPath

The filename of the input XML or HTML document.

System.String outputPath

A template string from which the raster files will be named (e.g. "page_%02d.png" will cause Prince to generate page_01.png, page_02.png, ..., page_10.png etc.).

Returns
Type Description
System.Boolean

true if the input was successfully rasterized.

| Improve this Doc View Source

RasterizeString(String, Stream)

Rasterize an XML or HTML string.

Declaration
public bool RasterizeString(string input, Stream output)
Parameters
Type Name Description
System.String input

The XML or HTML document in the form of a string.

Stream output

The output Stream to which Prince will write the raster output.

Returns
Type Description
System.Boolean

true if the input was successfully rasterized.

| Improve this Doc View Source

RasterizeString(String, String)

Rasterize an XML or HTML string.

Declaration
public bool RasterizeString(string input, string outputPath)
Parameters
Type Name Description
System.String input

The XML or HTML document in the form of a string.

System.String outputPath

A template string from which the raster files will be named (e.g. "page_%02d.png" will cause Prince to generate page_01.png, page_02.png, ..., page_10.png etc.).

Returns
Type Description
System.Boolean

true if the input was successfully rasterized.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX