iTextSharp - 2. Seite einlesen???

  • VB.NET

    iTextSharp - 2. Seite einlesen???

    Hallo liebe Gemeinde, ich bin neu hier und hoffe, dass jemand mir helfen kann.
    ich bin dabei derzeit ein kleines tool zu programmieren, dass pdf templates einliest und diese mit werten aus textboxen usw versieht. im anschluss speichert er mir die bearbeitete pdf ab.
    als dll nutze ich iTextSharp, das funktioniert auch super, nur leider kriege ich von meinem templates lediglich die erste seite eingelesen. folgende seiten werden einfach abgeschnitten.
    nun meine frage, wie bekomme ich es hin, dass das ganze dokument eingelesen wird?

    hier mein code:

    VB.NET-Quellcode

    1. If ComboBox1.SelectedItem = "DPD" Then
    2. Dim oldFile As String = "templates/dpd-schadenformular.pdf"
    3. Dim newFile As String = "output/DPD-Output.pdf"
    4. ' Create reader
    5. Dim reader As New PdfReader(oldFile)
    6. Dim size As Rectangle = reader.GetPageSizeWithRotation(1)
    7. Dim document As New Document(size)
    8. ' Create the writer
    9. Dim fs As New FileStream(newFile, FileMode.Create, FileAccess.Write)
    10. Dim writer As PdfWriter = PdfWriter.GetInstance(document, fs)
    11. document.Open()
    12. Dim cb As PdfContentByte = writer.DirectContent
    13. ' Set the font, color and size properties for writing text to the PDF
    14. Dim bf As BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
    15. cb.SetColorFill(BaseColor.DARK_GRAY)
    16. cb.SetFontAndSize(bf, 8)
    17. ' Write text in the PDF
    18. cb.BeginText()
    19. Dim kundennummer As String = "Kundennummer " & Form3.dpdkdnr.Text
    20. Dim trackid1 As String = track1.Text
    21. Dim trackid2 As String = track2.Text
    22. Dim descr As String = beschreibungschaden.Text
    23. Dim warenart As String = paketinhalt.Text
    24. Dim empfnam As String = empfnamebox.Text
    25. Dim empfstr As String = empfstrbox.Text
    26. Dim empfplz As String = empfplzbox.Text
    27. ' Set the alignment and coordinates here
    28. cb.ShowTextAligned(1, kundennummer, 360, 638, 0)
    29. cb.ShowTextAligned(1, trackid1, 336, 685, 0)
    30. cb.ShowTextAligned(1, trackid2, 430, 685, 0)
    31. cb.ShowTextAligned(1, descr, 150, 135, 0)
    32. cb.ShowTextAligned(1, warenart, 90, 235, 0)
    33. cb.ShowTextAligned(1, empfnam, 370, 441, 0)
    34. cb.ShowTextAligned(1, empfstr, 370, 416, 0)
    35. cb.ShowTextAligned(1, empfplz, 370, 381, 0)
    36. cb.EndText()
    37. ' Put the text on a new page in the PDF
    38. Dim page As PdfImportedPage = writer.GetImportedPage(reader, 1)
    39. cb.AddTemplate(page, 0, 0)
    40. ' Close the objects
    41. document.Close()
    42. fs.Close()
    43. writer.Close()
    44. reader.Close()
    45. ' -----------------------------------------------
    46. ' -----------------------------------------------
    47. ' --------------------- DPD Ende ----------------
    48. ' -----------------------------------------------
    49. ' -----------------------------------------------
    50. End If


    Hoffe jemand kann mir helfen, danke im Voraus

    Beste Grüße