Welcome Guest Search | Active Topics | Sign In | Register

Confusing API for EO.PDF Options
Linefeed
Posted: Thursday, May 12, 2011 4:58:43 AM
Rank: Newbie
Groups: Member

Joined: 5/12/2011
Posts: 2
I'm worried about the API when using it in a multi threaded web environment.

To set the HtmlPDfOptions you need to set the following for example:

Code: C#
HtmlToPdf.Options.HeaderHtmlFormat = "test";
HtmlToPdfResult htmlToPdfResult = HtmlToPdf.ConvertHtml(HtmlBody, pdfDocument);


yet, at the same time, on a different thread, I'm also converting html to pdf where no header is applicable.

I would expect more something like this:

Code: C#
HtmlToPdfOptions options = new HtmlToPdfOptions();
options.HeaderHtmlFormat = "test";

PdfDocument pdfDocument = new PdfDocument(options);  //<-- not possible
HtmlToPdfResult htmlToPdfResult = HtmlToPdf.ConvertHtml(HtmlBody, pdfDocument);


or like setting the info:

Code: C#
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.Info.Author = "Me";
pdfDocument.Options.HeaderHtmlFormat = "test";   //<-- not possible
HtmlToPdfResult htmlToPdfResult = HtmlToPdf.ConvertHtml(HtmlBody, pdfDocument);



or

Code: C#
HtmlToPdfResult result = HtmlToPdf.ConvertHtml(htmlBod, pdfdocument, options) //<-- not possible


Can you please advise why setting the options happen in a static way ?
Thx





eo_support
Posted: Thursday, May 12, 2011 7:41:56 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You would always use the static form:

Code: C#
//This is OK in a multi-thread environment
HtmlToPdf.Options.HeaderHtmlFormat = "test";


A separate static HtmlToPdf.Options instance is maintained for each thread. So you do not need to worry about multi-thread issue.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.