|
Rank: Newbie Groups: Member
Joined: 10/16/2012 Posts: 3
|
hello, Our client would like to remove the footer on the first page of the report. They don't need to display the footer on Page of content. Is there an option we can do that in EOPdf? Thank you in advance for your help. Please see the code below:
string outputFileName = @"C:\Temp\Test.pdf"; string htmlString = null; using (var streamReader = new StreamReader(@"C:\Temp\test.htm", Encoding.UTF8)) { htmlString = streamReader.ReadToEnd(); } // Add Footer using (var streamReader = new StreamReader(@"C:\Temp\Footer.htm", Encoding.UTF8)) { HtmlToPdf.Options.FooterHtmlFormat = streamReader.ReadToEnd(); } //Convert the HTML snippets into a PdfDocument object PdfDocument doc = new PdfDocument(); HtmlToPdfResult result = HtmlToPdf.ConvertHtml(htmlString, doc); doc.Save(outputFileName);
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
I am not exactly sure if I understood your question. The code you posted is for ADDING footer. Yet your question is about REMOVING footer. I would think if you do not want the footer you added, you just do not add it. But I would think your question is not that simple. Please clarify.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 10/16/2012 Posts: 3
|
We generate a pdf report with multiple pages (20 pages) and the footer added as expected. However, we would like to only remove the footer on the first page of the pdf report (Page 1 only). The reason is page 1 is Page of Content and we would like to make it looks nice and clean as our client requested. Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Oh. Then you would have to generate the footer separately. For example:
Code: C#
//Convert the main HTML
PdfDocument doc = new PdfDocument();
HtmlToPdfResult result = HtmlToPdf.ConvertHtml(htmlString, doc);
//Add the footer, starting from the second page
for (int i = 1; i < doc.Pages.Count; i++)
{
//Set OutputArea differently to position the footer properly
HtmlToPdf.Options.OutputArea = .....
//Add footer to the page. Note the second argument is a PdfPage
HtmlToPdf.ConvertHtml(footerHtml, doc.Pages[i]);
}
If your footer is simple text, you can use ACM interface (PDF Creator) to render the footer. It's more code but will be much faster than calling ConvertHtml on each page. You can take a look of the PDF creator interface documentation/samples for more information. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 10/16/2012 Posts: 3
|
Very nice and thanks for such a quick response!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
You are very welcome. Please feel free to let us know if there is anything else.
|
|