Prince C# Wrapper Documentation

Prince C# class

The prince.cs file defines a class called Prince that contains methods that can be called to convert XML and HTML documents into PDF.

There is a public interface called PrinceEvents which can be implemented by the user to allow messages from Prince to be handled during conversion.

Constructors

public Prince(string princePath)
Example: Prince prn = new Prince("C:\\Program Files\\Prince\\Engine\\bin\\prince.exe");
public Prince(string princePath, PrinceEvents events)
Example: Prince prn = new Prince("C:\\Program Files\\Prince\\Engine\\bin\\prince.exe", events);

On Windows, be sure to specify the path to the prince.exe file located within the Engine\bin subfolder of the Prince installation.

Conversion methods

public bool Convert(string xmlPath)
Convert an XML or HTML file to a PDF file.
public bool Convert(string xmlPath, string pdfPath)
Convert an XML or HTML file to a PDF file specified by pdfPath.
public bool ConvertMultiple(string[] xmlPaths, string pdfPath)
Convert multiple XML or HTML files to a PDF file specified by pdfPath.
public bool Convert(string xmlPath, Stream pdfOutput)
Convert an XML or HTML file to a PDF which is written to the stream specified by pdfOutput.
public bool Convert(Stream xmlInput, string pdfPath)
Convert the XML or HTML read from stream xmlIput to a PDF file specified by pdfPath.
public bool Convert(Stream xmlInput, Stream pdfOutput)
Convert the XML or HTML read from stream xmlIput to a PDF which is written to the stream specified by pdfOutput.
public bool ConvertMemoryStream(MemoryStream xmlInput, Stream pdfOutput)
Convert the XML or HTML read from MemoryStream xmlInput to a PDF which is written to the stream specified by pdfOutput.
public bool ConvertString(string xmlInput, Stream pdfOutput)
Convert the XML or HTML read from the string xmlInput to a PDF which is written to the stream specified by pdfOutput.

Configuration methods

public void AddStyleSheet(string cssPath)
Add the CSS style sheet specified by cssPath. It will be applied to each input document. Multiple style sheets can be accumulated by calling the function repeatedly.
public void ClearStyleSheets()
Clear all of the CSS style sheets accumulated.
public void AddScript(string jsPath)
Add a JavaScript specified by jsPath. Multiple JavaScript's can be added by calling the function repeatedly.
public void ClearScripts()
Clear all Javascript's.
public void AddFileAttachment(string filePath)
Add a file attachment specified by filePath that will be attached to the PDF file. Multiple file attachments can be added by calling the function repeatedly.
public void ClearFileAttachments()
Clear all of the file attachments.
public void SetLicenseFile(string file)
Notify Prince the license file.
public void SetLicensekey(string key)
Set the license key.
public void SetInputType(string inputType)
Specify the input type of the document. The inputType value can be: "xml", "html" or "auto".
public void SetJavaScript(bool js)
Specify whether to run Javascripts in documents.
public void SetHttpUser(string user)
Specify the username to use when accessing remote resources over HTTP.
public void SetHttpPassword(string password)
Specify the password to use when accessing remote resources over HTTP
public void SetHttpProxy(string proxy)
Specify the URL for the HTTP proxy server, if needed.
public void SetInsecure(bool insecure)
Specify whether to disable SSL verification. If set to true, SSL verification is disabled. (not recommended)
public void SetHTML(bool html)
If set true, document will be parsed as HTML. If set false, document will be parsed as XML.
public void SetLog(string logFile)
Specify the log file for writing error/warning messages.
public void SetBaseURL(string baseURL)
Specify the base URL of the input document. baseURL is the base URL, or the path of the input document, or ''.
public void SetFileRoot(string fileRoot)
Specify the root directory for absolute filenames. This can be used when converting a local file that uses absolute paths to refer to web resources. For example, /images/logo.jpg can be rewritten to /usr/share/images/logo.jpg by specifying "/usr/share" as the root.
public void SetXInclude(bool xInclude)
Specify whether XML Inclusions (XInclude) processing should be applied to input documents. XInclude processing will be performed by default unless explicitly disabled.
public void SetEmbedFonts(bool embed)
Specify whether fonts should be embedded in the output PDF file. Fonts are embedded by default unless explicitly disabled.
public void SetSubsetFonts(bool subset)
Specify whether embedded fonts should be subset in the output PDF file. Fonts are subset by default unless explicitly disabled.
public void SetCompress(bool compress)
Specfy whether compression should be applied to the output PDF file. Compression is applied by default unless explicitly disabled.
public void SetNoArtificialFonts(bool noArtificialFonts)
Specify whether artificial bold/italic fonts should be generated if necessary. Artificial fonts are enabled by default.
public void SetPDFTitle(string pdfTitle)
Specify the document title for PDF metadata.
public void SetPDFSubject(string pdfSubject)
Specify the document subject for PDF metadata.
public void SetPDFAuthor(string pdfAuthor)
Specify the document author for PDF metadata.
public void SetPDFKeywords(string pdfKeywords)
Specify the document keywords for PDF metadata.
public void SetPDFCreator(string pdfCreator)
Specify the document creator for PDF metadata.
public void SetAuthMethod(string authMethod)
Specify HTTP authentication methods. (basic, digest, ntlm, negotiate)
public void SetAuthUser(string authUser)
Specify username for HTTP authentication.
public void SetAuthPassword(string authPassword)
Specify password for HTTP authentication.
public void SetAuthServer(string authServer)
Only send USER:PASS to this server.
public void SetAuthScheme(string authScheme)
Only send USER:PASS for this scheme. (HTTP, HTTPS)
public void SetNoAuthPreemptive(bool noAuthPreemptive)
Do not authenticate with named servers until asked.
public void SetPageSize(string pageSize)
Specify the page size (eg. A4).
public void SetPageMargin(string pageMargin)
Specify the page margin (eg. 20mm).
public void SetEncrypt(bool encrypt)
Specify whether to apply encryption to the output PDF file. The default is no encryption.
public void SetEncryptInfo(int keyBits, string userPassword, string ownerPassword, bool disallowPrint, bool disallowModify, bool disallowCopy, bool disallowAnnotate)
Set the parameters used for PDF encryption. Calling this method will also enable encryption, equivalent to calling setEncrypt(true). It should be called before calling a convert method for encryption information to be applied.
public void SetOptions(string options)
Set other options.

Copyright © 2005-2015 YesLogic Pty. Ltd.