c# - Page Control while HTML to PDF Conversion using Select PDF -


i trying convert large html file pdf. want set first page , following page number.

i have used following code

        converter = new htmltopdf()         dim file string = "c:\temp\document5.pdf"          converter.options.pdfpagesize = pdfpagesize.a4         converter.options.pdfpageorientation = pdfpageorientation.portrait         converter.options.margintop = 20         converter.options.marginbottom = 20         converter.options.marginleft = 10         converter.options.marginright = 10         converter.options.displayfooter = true          dim doc pdfdocument = converter.converthtmlstring(htmlstring)          converter.footer.totalpagesoffset =2           converter.footer.firstpagenumber = 2           doc.save(file)              ' close pdf document          doc.close() 

but part not working,

        converter.footer.totalpagesoffset =2           converter.footer.firstpagenumber = 2  

and there know total pages?

here's how handle page numbering using selectpdf , asp.net mvc razor.

for (int x = 0; x < pdf.pages.count; x++) {     if (x > 0 && x != pdf.pages.count - 1) { // not number first/last page         pdfpage page = pdf.pages[x];         pdftemplate customfooter = pdf.addtemplate(page.pagesize.width, 33f);         page.displayfooter = true;         pdfhtmlelement customhtml = new pdfhtmlelement(domain + "/template/_pagenumber?pagenum=" + x.tostring() + "&totalpages=" + pdf.pages.count.tostring());         customfooter.add(customhtml);         page.customfooter = customfooter;     } } 

and here's _pagenumber.cshtml file looks like...

<div style="margin-right:48px;margin-left:48px;height:46px;position:relative;top:-4px;z-index:999;">     <div class="row">         <div class="col-xs-6">             <small>company info goes here</small>         </div>         <div class="col-xs-6 text-right">             <small><strong>page @(request.querystring["pagenum"]) of @(request.querystring["totalpages"])</strong></small>         </div>     </div> </div> 

Comments