I am just starting to use SPIRE PDF and am trying to find a good example of have a certain number of pages added
based on the string that is sent as input to be posted to the PDF document.
My issue is that the PDF document is generated but not in the right sequence and with some blank pages:
- Code: Select all
Public Sub createNewINVprnFile(ByVal streamout As String, ByVal fileout As String, ByVal pageCount As Integer)
Dim indx As Int16 = 0
Dim doc As New PdfDocument()
Dim pages() As String
Dim page As PdfPageBase = doc.Pages.Add(PdfPageSize.A3)
pages = Split(streamout, vbFormFeed, , vbTextCompare)
For x = 0 To pageCount - 1
page.Document.PageSettings.Orientation = PdfPageOrientation.Landscape
page.Canvas.DrawString(pages(x), New PdfFont(PdfFontFamily.Courier, 10.0F), New PdfSolidBrush(Color.Black), 10, 10)
page = doc.Pages.Add()
Next
doc.SaveToFile(fileout) doc.SaveToFile(fileout)
End Sub
The outcoming PDF document should have 5 pages as that is what the streamout string contains.
The resulting document
Page 1 of 5
Page 2 of 5
Page 4 of 5
Page 5 of 5
Blank
Page 3 of 5
Not sure what could be the issue, My input string has the right sequence I am checking it for ff and other control characters .. but would appreciate any help.
This is the first .NET code I wrote in order to use SPIRE pdf if there are some inefficiencies or improvements to the code, please
let me know