PDFsharp - How to create a 2nd page

前端 未结 4 799
悲哀的现实
悲哀的现实 2020-12-06 13:58

I can\'t find documentation in PDFsharp to show how to add a 2nd page using C#!

As an example, over in VB6 I use a PDF creation method called mjwPDF. To indicate th

4条回答
  •  温柔的废话
    2020-12-06 14:08

    you can print in multiple pages by decreasing the size of "Ypoint" as shown below code.

    its given value is "yPoint = yPoint + 40"

    change it to "yPoint = yPoint + 8" i.e increment ypoint by +8 in every loop iteration,

    reply for any doubts. refer while loop below

            While dr.Read
    
                username = dr.Item(0)
                Action_Performed = dr.Item(1)
                datetim = dr.Item(2)
    
                graph.DrawString(username, font, XBrushes.Black, _
                   New XRect(40, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)
    
                graph.DrawString(Action_Performed, font, XBrushes.Black, _
                  New XRect(280, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)
    
                graph.DrawString(datetim, font, XBrushes.Black, _
                   New XRect(420, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)
                yPoint = yPoint + 10
                counter += 1
                If counter = 30 Then
                    pdfPage = pdf.AddPage()
                    graph.Dispose()
                    graph = XGraphics.FromPdfPage(pdfPage)
                    font = New XFont("Verdana", 7, XFontStyle.Regular)
                    yPoint = 0
                    yPoint = yPoint + 100
                    counter = 0
                End If
            End While
            Dim pdfFilename As String = "dbtopdf.pdf"
            pdf.Save(pdfFilename)
            Process.Start(pdfFilename)
    

    regards, Shivanand

提交回复
热议问题