Generate a PDF document from dynamically built HTML content.
Key Objects Used
finFileDownloadInfo
finBL.HtmlEncode
Code
Dim FileInfo As finFileDownloadInfo
Dim sb AsNew StringBuilder()
' Build HTML content with PDF meta tagsWith sb
.Append("<html>")
.Append("<head>")
.Append("<meta name='pdf-PageSize' content='A4'/>")
.Append("<meta name='pdf-PageOrientation' content='Portrait'/>")
.Append("<meta name='pdf-LeftMargin' content='1.5cm'/>")
.Append("<meta name='pdf-RightMargin' content='1.5cm'/>")
.Append("</head>")
.Append("<body>")
.Append("<h1>Report Title</h1>")
' Always HTML-encode user input for security
.AppendFormat("<p>{0}</p>", finBL.HtmlEncode(userNotes, True, True))
.Append("</body>")
.Append("</html>")
End With' Generate PDF
FileInfo = finBL.CreateFileDownloadInfo()
If FileInfo.LoadPdfFromHtml(sb.ToString(), "report.pdf") Then' FileInfo.ToXmlString() returns the file for downloadEnd If