Hello,
We are entering the production phase of a roll-out with Prince converting XHTML documents to PDF format using the .NET interface and we are trying to eke out every bit of performance that we can. Not knowing what goes on inside the Prince engine I'd like some feedback on how we are using Prince to see if the experts can advise on possible performance increases.
The XML document passed into the Render method below is and HTML document that mostly passes the XHTML Transitional validation. The only things that are not compliant are a few attributes we use on a few HTML elements.
Here is our code that interfaces with the Prince engine:
We do reference about 12 - 15 CSS files from the <head> section of the document. We have considered merging them into one or two but initial tests do not indicate that will buy us much. We are reading the CSS files directly from a local file system so there is no network latency involved in picking up all the various CSS files.
Any advice or tips?
Thank you.
Adrian Pfisterer
Healthwise, Inc.
We are entering the production phase of a roll-out with Prince converting XHTML documents to PDF format using the .NET interface and we are trying to eke out every bit of performance that we can. Not knowing what goes on inside the Prince engine I'd like some feedback on how we are using Prince to see if the experts can advise on possible performance increases.
The XML document passed into the Render method below is and HTML document that mostly passes the XHTML Transitional validation. The only things that are not compliant are a few attributes we use on a few HTML elements.
Here is our code that interfaces with the Prince engine:
public MimeStream Render(XmlDocument doc)
{
XmlNamespaceManager nsm = new XmlNamespaceManager(doc.NameTable);
nsm.AddNamespace("xhtml", "http://www.w3.org/1999/xhtml");
var p = new Prince(princeEnginePath);
p.SetHTML(true);
string baseURL = string.Format("file:///{0}/hwxml/hwxml/",
Path.Combine(this.baseResourcePath, getLocalizationFromDoc(doc, nsm)));
baseURL = baseURL.Replace("\\", "/");
p.SetBaseURL(baseURL);
MemoryStream outMemStream = new MemoryStream(100000);
bool result;
try
{
result = p.ConvertString(doc.OuterXml, outMemStream);
}
catch (Exception ex)
{
throw new PrintException("Exception in Prince PDF rendering engine: " + ex.Message);
}
if(result == false)
throw new PrintException("Error converting document to PDF in Prince rendering engine.");
outMemStream.Seek(0, SeekOrigin.Begin);
return new MimeStream("application/pdf", outMemStream);
}
We do reference about 12 - 15 CSS files from the <head> section of the document. We have considered merging them into one or two but initial tests do not indicate that will buy us much. We are reading the CSS files directly from a local file system so there is no network latency involved in picking up all the various CSS files.
Any advice or tips?
Thank you.
Adrian Pfisterer
Healthwise, Inc.