Rotativa PDF MVC3 Paging - c#

Am using Rotativa to create pdfs in my mvc4 application. Problem is how do i get display page numbers on the pdfs.

This code will give you a page number at the center of the footer.
return new Rotativa.ViewAsPdf()
{
CustomSwitches = "--page-offset 0 --footer-center [page] --footer-font-size 8"
}
Use --page-offset option to set the starting page number.
Set the page offset to 0 and the page number will start at 1 (This is also the default option).
Font size can be controlled by specifying the --footer-font-size option.

You should be able to leverage page footer options on wkhtmltopdf by adding a CustomSwitches property to Rotativa *AsPdf.
Take a look at http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html

Related

Finding a number in a website and displaying it

I want to take the "total member" number (on the right bar of the website) and display that number inside a label in C# windows form application. Here is the website: https://www.dojrp.com/
Thanks
Here is a solution to solve your problem:
Step 1. Get the html code of this website page using System.Net.WebClient class.
Step 2. Locate the "total member" number in the html code and get it using System.Text.RegularExpressions.Regex class.
Step 3. Assign that number to your label on your windows form.

How to change the page size of one of the pages in a existing PDF using ABCPdf

I have an existing PDF. The page size of the entire document is A4. If I would like to modify the page size of the 2nd page to Legal then How can I achieve that using ABCPdf?
Thanks
Did you try something like that?
Using yourDoc As New Doc()
With yourDoc
.Read (yourpath)
.PageNumber =2
.MediaBox.String = "Legal"
.Save(new_path)
.Clear()
End With
End Using
Page sizes:
http://www.websupergoo.com/helppdfnet/source/5-abcpdf/xrect/2-properties/string.htm

Rotativa - Wkhtmltopdf: Add footer chinese text?

I am trying to add a footer to the page that shows the page number what looks like this
"Page 1 of 10" in Chinese using Rotativa HTML to PDF library.
This is set by the CustomSwitches attribute.
My code is like this
ViewAsPdf pdfView = new ViewAsPdf("Index", Model)
{
FileName = fileName,
PageOrientation = pageOrientation,
PageSize = Size.A4,
IsJavaScriptDisabled = isJavaScriptDisabled,
CustomSwitches = "--disable-external-links --disable-internal-links --footer-center \"Page [page] of [toPage]\" --footer-font-size 7"
};
This works great.
But if I change the text to Chinese it does not render the characters right
--footer-center \"第 [page] 页, 共 [toPage] 页\"
I understand the this CustomSwitches calls wkHtmltoPDF, but did not find anything there either. The html page that contains Chinese characters renders just fine.
The answer is that the custom switches are a command line argument for the WkhtmltoPDF.
In order to make it work you have to go to Control panel -> Region and language -> Administrative -> Change system locale... -> in this case I selected Chinese (Simplified, PRC)

Switch HTML page to media print mode

Is there a way to switch an HTML page to "print" mode?
When I print, a #media print style-sheet gets applied to the page.
I want to use the page with that print style applied to export to PDF as well. Ideally, if I could get the HTML that gets sent to the printer when I use window.print() I could export it to PDF. I use a server side library and C# to export to PDF.
Any ideas on how I can do this?
Thank you!
As per W3C standars there is no distinctive print mode for web pages except that you can define different CSS rules for #screen and #print media.
If you want to render a page as it is shown in print view somewhere it is show in screen view; use #print CSS for #screen also.

Preview the text contents from HtmlEditor control(ajax) on A4 size paper and save it as .txt

I am doing asp.net project using C#.I want to display the contents that are being typed in HtmlEditor control onto a A4 size as preview and i also want to save this content to a file(.doc or .txt).
How do i do it??
Please help
You can bind html editor content in variable and then display variable in client side.
server side:
Private static string abc=string.empty;
abc=htmlcontrolname.content;
databind();
on client side:
<%= abc%>
Set page size
There is no way with JavaScript, HTML, CSS currently to set the page size for printing. It is in the CSS spec, but there is very limited support for it.
Save file
There is no IO in JavaScript. The best bet is to send the content to the server and return headers that force a downoad of the file.

Categories

Resources