Hi,
I create a Pdf file that has the first page with left margin having image embedded so the wording content of the page needs to have certain left margin. On the second page onward, the content then needs not to have that left margin any more.
When I create the file, for the first page, I need to do 2 drawing, one is the wording content of the page and the second drawing is to put the left margin image onto the page. However, my left margin image gets cut off on the left and the text seems to be obscured possibly because of the margin.
Any thoughts on how should I set the pages for my Pdf file so that I can have the first page with left margin image and the second page onward does not have left margin at all.
Here is how I create my Pdf file in vb.net:
Dim letterStr As String = "............." 'content of the file that spans few pages in the Pdf file
If Not String.IsNullOrEmpty(letterStr) Then
Dim section As IWSection
Dim letterDoc As WordDocument = Nothing
Dim converter As New DocToPDFConverter()
Dim pdfLetter As Syncfusion.Pdf.PdfDocument = New Syncfusion.Pdf.PdfDocument()
pdfLetter.PageSettings.Margins.Top = -3
pdfLetter.PageSettings.Margins.Left = 0
letterDoc = New WordDocument()
section = letterDoc.AddSection()
letterDoc.XHTMLValidateOption = XHTMLValidationType.None
section.Body.InsertXHTML(letterStr)
pdfLetter = converter.ConvertToPDF(letterDoc)
If Not IsNothing(pdfLetter) Then
Dim dataPath As String = HttpContext.Current.Server.MapPath("~/App_Data/LetterHeader.pdf") 'THIS IS THE LETTER HEAD TEMPLATE THAT CREATES THE LEFT MARGIN IMAGE AND HEADER, FOOTER
Dim letterHeadFS As Stream = New FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim letterHeadDoc As New Syncfusion.Pdf.Parsing.PdfLoadedDocument(letterHeadFS)
For i As Integer = 0 To pdfLetter.Pages.Count - 1
Dim section As PdfSection = doc.Sections.Add
If i = 0 Then
section.PageSettings.Margins.Left = 70
Else
section.PageSettings.Margins.Left = 0
End If
Dim page As Syncfusion.Pdf.PdfPage = doc.Pages.Add
Dim g As PdfGraphics = page.Graphics
Dim lpage As PdfPageBase = pdfLetter.Pages(i)
Dim template As Syncfusion.Pdf.Graphics.PdfTemplate = lpage.CreateTemplate
g.DrawPdfTemplate(template, PointF.Empty, page.GetClientSize)
If i = 0 Then
section.PageSettings.Margins.Left = -40
lpage = letterHeadDoc.Pages(0)
template = lpage.CreateTemplate
g.DrawPdfTemplate(template, New PointF(-100, 0), page.GetClientSize)
End If
End If
End If
Thank you.
Vanna Le