Hello.
I convert HTML string to PDF using Spire.pdf.dll. However, when I set margins it cuts the content of page on the right. here is the code that I have. Any suggestions are very much appreciated.
Shared Sub ConvertHtmlToPdf(ByVal strHTML As String, ByVal PdfFileName As String)
Dim pdfDoc As PdfDocument = New PdfDocument
Dim pdfSetting As PdfPageSettings = New PdfPageSettings
Dim pdfFormat As HtmlConverter.PdfHtmlLayoutFormat = New HtmlConverter.PdfHtmlLayoutFormat
pdfDoc.CompressionLevel = PdfCompressionLevel.BestSpeed
pdfDoc.DocumentInformation.Author = "Wespath Benefits and Investments"
pdfDoc.PageScaling = PdfPrintPageScaling.FitSize <--------- I played with all options already
pdfDoc.UseHighQualityImage = True
'pdfFormat.Layout = Graphics.PdfLayoutType.Paginate
pdfFormat.FitToPage = HtmlConverter.Clip.Both
pdfSetting.Size = PdfPageSize.Letter
pdfSetting.Orientation = PdfPageOrientation.Portrait
pdfSetting.Margins.Left = 60
pdfSetting.Margins.Right = 35
pdfSetting.Margins.Top = 35
pdfSetting.Margins.Bottom = 26
pdfDoc.LoadFromHTML(strHTML, True, pdfSetting, pdfFormat)
pdfDoc.SaveToFile(PdfFileName, FileFormat.PDF)
pdfDoc.Close()
End Sub
Tanya Lerner
tlerner@wespath.org