Page counter for HTML Renderer for PDF using PDFSharp - c#

I would like to put the page number of each page of a pdf file generated by HTML Renderer for PDF using PDFSharp which is an amazing plugin using PDFSharp and giving the possibility to render a pdf file from html string, moreover it supports CSS 2 to style the generated pdf.
Thanks to this pull request, which is available in the beta version, it is possible to have a proper paging with elements not being cut when they are taller than the page format.
I tried using this in the css:
.footer:after
{
counter-increment: page;
content: counter(page);
}
with no success (the footer being in a fixed position). I would like to know if someone achieved a proper page count with this plugin or if someone knew another way.
I already tried to simulate the pages count the document would take but the styling in browser is quite different from the generated pdf file (lines height, margins management, etc).

Related

Convert asp.net page to Word document

I have built several PDF documents dynamically from ASP.NET pages (HTML/CSS) using plugins like Winnovative HtmlToPDFconverter. It has always been a successful outcome using the built-in functionality for those plugins, like merging existing PDF documents with dynamic content and adding pre-defined headers and footers, adding page margins, page numbers and so forth. The HTML content has overall been rendered as expected in the final PDF document(s).
Is there any way/any advice for a similar .NET plugin that can render HTML/CSHTML to a Microsoft Word document (.docx) in the same way – or is it too difficult to render native HTML5 and CSS into a desirable layout for a Microsoft Word Document?
I have googled around and found some suggestions, but I'm looking for recommendations for maybe a specific plugin – or a warning if it is a no-go
and too difficult to get the desired layout 1:1 from HTML to a Word document because of incompatibility between markups?
Devexpress HTML editor can export its HTML content to different formats including docx and rtf. Not sure about its limitations (e.g. script and canvas export, etc.), but in the common case it works well.

PDF Generation dynamically

I am working on PDF generation dynamically, I have pdf template and I am creating the similar dynamically using ITextSharp,I am creating the pdf and returning base64 string to mobile app,which then convert the base64 to pdf.
The template is like this
See Image
The footer's disclaimer and page number will appear in all pages of PDF file, and page number is dynamic too.
I have created it successfully, it is not exactly same as of the template, Is there any other way to generate PDF without ITextsharp?
Can I use crystal report or RDLC for this or any other,that fulfils my requirements.(dynamic page number,disclaimer and page in all pages and base64 string).
The content of center table can be multiple ,so the pdf can be of more then one pages.
The difference of generated pdf is that center's table width is going out,it should align with top two tables(I have 100% for three tables),there are other issues as well.
Generating footer and header with ItextSharp is not native,
so you need to code it manually.
Here, is a good Example:
https://www.codeproject.com/Tips/573907/Generating-PDF-using-ItextSharp-with-Footer-in-Csh

Itextsharp and css

I am using iTextSharp to generate a pdf invoice.
I have a template for the invoice which is very simple, but uses CSS3 for the formatting and styling.
when I display the page in a browser it works fine, but when I try to generate the page into a pdf using itextsharp it seems to ignore all the CSS3 formatting for some reason.
My question is: Is there a way to get it to work with CSS? Or is that a limitation of iTextSharp ?
Are your stylesheets linked with an absolute path or a relative one? PDF converters don't tend to work too well with relative paths.

asp.net html 2 pdf and overlay pdf file

i want to generate a PDF file with tables, etc in it. so what i did is using a PDF converter (EVO PDF). that works great, except that the PDF has a white background-color.
What I wanted to do is to overlay a PDF document (because our company paperwork) and put the HTML above it. But because the HTML has a white background, I can't get it work.
I'm now using EVOPDF to generate the HTML and Syncfusion to overlay the company paperwork..
there must be an easier way
Convert the company stationary into a flat image, and then set that as the background to the page in CSS. As long as care is taken to measure and set sizing right, that should work for you.

Split a large html document by page

I have a very long article with over 50 pages in length in a single HTML document. I would like to know if there's an algorithm that can split the HTML document by page (A4 sized page), kind of like the print preview function, into smaller files for each page while maintaining proper formatting.
I use .NET 4.0 C#
This doesn't always work, but sometimes you can print the document to PDF, split the PDF into one PDF per page, and convert those PDFs to HTML files. The result isn't always pretty, though.
You can use HTMLDOC to split HTML into pages:
Here's a blogpost explaining the process
Have you tried using a virtual printer such as CutePDF and print the document to a PDF? Also, according to the website I linked, CutePDF has it's own SDK.
It's not clear why do you want to do so, but, try simply opening your page in Microsoft Word. Microsoft Word has the "Print Layout" where you will see your document by page. Eventually you will be able to edit it to make it fit.

Categories