Guest User

Untitled

a guest
Mar 22nd, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. converter = New HtmlToPdf()
  2. Dim file As String = "C:TEMPDocument5.pdf"
  3.  
  4. converter.Options.PdfPageSize = PdfPageSize.A4
  5. converter.Options.PdfPageOrientation = PdfPageOrientation.Portrait
  6. converter.Options.MarginTop = 20
  7. converter.Options.MarginBottom = 20
  8. converter.Options.MarginLeft = 10
  9. converter.Options.MarginRight = 10
  10. converter.Options.DisplayFooter = True
  11.  
  12. Dim doc As PdfDocument = converter.ConvertHtmlString(htmlString)
  13.  
  14. converter.Footer.TotalPagesOffset =2
  15. converter.Footer.FirstPageNumber = 2
  16.  
  17. doc.Save(file)
  18.  
  19. ' close pdf document
  20. doc.Close()
  21.  
  22. converter.Footer.TotalPagesOffset =2
  23. converter.Footer.FirstPageNumber = 2
  24.  
  25. for (int x = 0; x < PDF.Pages.Count; x++) {
  26. if (x > 0 && x != PDF.Pages.Count - 1) { // will not number first/last page
  27. PdfPage page = PDF.Pages[x];
  28. PdfTemplate customFooter = PDF.AddTemplate(page.PageSize.Width, 33f);
  29. page.DisplayFooter = true;
  30. PdfHtmlElement customHtml = new PdfHtmlElement(domain + "/template/_pagenumber?pageNum=" + x.ToString() + "&totalPages=" + PDF.Pages.Count.ToString());
  31. customFooter.Add(customHtml);
  32. page.CustomFooter = customFooter;
  33. }
  34. }
  35.  
  36. <div style="margin-right:48px;margin-left:48px;height:46px;position:relative;top:-4px;z-index:999;">
  37. <div class="row">
  38. <div class="col-xs-6">
  39. <small>Company info goes here</small>
  40. </div>
  41. <div class="col-xs-6 text-right">
  42. <small><strong>Page @(Request.QueryString["pageNum"]) of @(Request.QueryString["totalPages"])</strong></small>
  43. </div>
  44. </div>
  45. </div>
Add Comment
Please, Sign In to add comment