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.
public Prince(string princePath)
Prince prn = new Prince("C:\\Program Files\\Prince\\Engine\\bin\\prince.exe");
public Prince(string princePath, PrinceEvents events)
PrinceEvents
and make
an instance of that class.Prince
constructor: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.
public bool Convert(string xmlPath)
public bool Convert(string xmlPath, string pdfPath)
pdfPath
.public bool ConvertMultiple(string[] xmlPaths, string pdfPath)
pdfPath
.public bool Convert(string xmlPath, Stream pdfOutput)
pdfOutput
.public bool Convert(Stream xmlInput, string pdfPath)
xmlIput
to a PDF file specified by pdfPath
.public bool Convert(Stream xmlInput, Stream pdfOutput)
xmlIput
to a PDF which is written to the stream specified by pdfOutput
.public bool ConvertMemoryStream(MemoryStream xmlInput, Stream pdfOutput)
MemoryStream
xmlInput
to a PDF which is written to
the stream specified by pdfOutput
.public bool ConvertString(string xmlInput, Stream pdfOutput)
xmlInput
to a PDF which is written
to the stream specified by pdfOutput
.public void AddStyleSheet(string cssPath)
cssPath
.
It will be applied to each input document.
Multiple style sheets can be accumulated by calling the function repeatedly.public void ClearStyleSheets()
public void AddScript(string jsPath)
jsPath
.
Multiple JavaScript's can be added by calling the function repeatedly.public void ClearScripts()
public void AddFileAttachment(string filePath)
filePath
that will be attached to the PDF file.
Multiple file attachments can be added by calling the function repeatedly.public void ClearFileAttachments()
public void SetLicenseFile(string file)
public void SetLicensekey(string key)
public void SetInputType(string inputType)
xml
", "html
" or "auto
".public void SetJavaScript(bool js)
public void SetHttpUser(string user)
public void SetHttpPassword(string password)
public void SetHttpProxy(string proxy)
public void SetInsecure(bool insecure)
public void SetHTML(bool html)
true
, document will be parsed as HTML.
If set false
, document will be parsed as XML.public void SetLog(string logFile)
public void SetBaseURL(string baseURL)
baseURL
is the base URL, or the path of the input document, or ''.public void SetFileRoot(string fileRoot)
/images/logo.jpg
can be rewritten to /usr/share/images/logo.jpg
by specifying "/usr/share"
as the root.public void SetXInclude(bool xInclude)
public void SetEmbedFonts(bool embed)
public void SetSubsetFonts(bool subset)
public void SetCompress(bool compress)
public void SetNoArtificialFonts(bool noArtificialFonts)
public void SetPDFTitle(string pdfTitle)
public void SetPDFSubject(string pdfSubject)
public void SetPDFAuthor(string pdfAuthor)
public void SetPDFKeywords(string pdfKeywords)
public void SetPDFCreator(string pdfCreator)
public void SetAuthMethod(string authMethod)
basic
, digest
, ntlm
, negotiate
)public void SetAuthUser(string authUser)
public void SetAuthPassword(string authPassword)
public void SetAuthServer(string authServer)
public void SetAuthScheme(string authScheme)
public void SetNoAuthPreemptive(bool noAuthPreemptive)
public void SetPageSize(string pageSize)
A4
).public void SetPageMargin(string pageMargin)
20mm
).public void SetEncrypt(bool encrypt)
public void SetEncryptInfo(int keyBits,
string userPassword,
string ownerPassword,
bool disallowPrint,
bool disallowModify,
bool disallowCopy,
bool disallowAnnotate)
keyBits
: The size of the encryption key in bits (must be
40 or
128).userPassword
: The user password for the PDF file (may be empty).ownerPassword
: The owner password for the PDF file (may be empty).disallowPrint
: True to disallow printing of the PDF file.disallowModify
: True to disallow modification of the PDF file.disallowCopy
: True to disallow copying from the PDF file.disallowAnnotate
: True to disallow annotation of the PDF file.public void SetOptions(string options)
Copyright © 2005-2015 YesLogic Pty. Ltd.