Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Apr 30, 2021 4:14 am

Hi,

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

aabruzzese
 
Posts: 1
Joined: Thu Apr 29, 2021 6:18 am

Fri Apr 30, 2021 8:06 am

Hello,

Thanks for your inquiry.
Please refer to the modified code below.
If you encounter any issues related to our product in the future, just feel free to contact us.

Code: Select all
 Public Sub createNewINVprnFile(ByVal streamout As String, ByVal fileout As String, ByVal pageCount As Integer)

        Dim indx As Int16 = 0
        Dim page As PdfPageBase = Nothing
        Dim doc As New PdfDocument()
        Dim pages() As String

        pages = Split(streamout, vbFormFeed, , vbTextCompare)
        For x = 0 To pageCount - 1
            page = doc.Pages.Add(PdfPageSize.A3)
            page.Document.PageSettings.Orientation = PdfPageOrientation.Landscape
            page.Canvas.DrawString(pages(x), New PdfFont(PdfFontFamily.Courier, 10.0F), New PdfSolidBrush(Color.Black), 10, 10)
        Next

        doc.SaveToFile(fileout)

    End Sub
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Sat May 08, 2021 8:21 am

Hi,

Greetings from E-iceblue!
Has the issue been solved now? Could you please give us some feedback at your convenience?
Thanks in advance.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.PDF