PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

pagina toevoegen aan pdfsharp document
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4147
Page 1 of 1

Author:  kees50 [ Fri Jun 19, 2020 6:44 pm ]
Post subject:  pagina toevoegen aan pdfsharp document

Hallo
ik werk in vb.net met pdfsharp en wil een nieuwe pagina openen en daar verder op werken maar hij gaat door op de vorige pagina en niet op de nieuwe
Wat doe ik fout wat doe ik fout ????

Dim pdf As PdfDocument = New PdfDocument
Dim pdfPage As PdfPage = pdf.AddPage
Dim graph As XGraphics = XGraphics.FromPdfPage(pdfPage)
Dim font As XFont = New XFont("courier new", 11, XFontStyle.Regular)
pdf.Info.Title = "My First PDF"
'#################### afbeelding plaatsen
strBestand = LocatieFotos & "\brief_96dpi.jpg"
graph.DrawImage(System.Drawing.Bitmap.FromFile(strBestand), 10, 10, 575, 110)

strBestand = (LocatieFotos & "\knab_bank_rode_balk_facturen_96dpi.jpg")
graph.DrawImage(System.Drawing.Bitmap.FromFile(strBestand), 10, 785, 575, 20) ''links 10 , hoogte

''################## tekst plaatsen
graph.DrawString("1", font, XBrushes.Black, _
New XRect(400, 120, pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString("2", font, XBrushes.Black, _
New XRect(400, 135, pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString("3", font, XBrushes.Black, _
New XRect(400, 150, pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString("4", font, XBrushes.Black, _
New XRect(400, 165, pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

'' ################# nieuwe pagina openen ###########################
pdf.AddPage()

graph.DrawString("tweede blad", font, XBrushes.Black, _
New XRect(150, 300, pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)


Dim pdfFilename As String = "C:\Users\kees\Dropbox\Fotos_Program_Woodart\Nieuwe PDF\De eerste PDF.pdf"
pdf.Save(pdfFilename)
pdf.Close()
Process.Start(pdfFilename)

Author:  TH-Soft [ Mon Jun 22, 2020 12:18 pm ]
Post subject:  Re: pagina toevoegen aan pdfsharp document

You do not use the result of "pdf.AddPage()", so the second page is added but the drawing is still done on the first page.

Use the new page and a new XGraphics object for the new page:
Code:
graph.Dispose()
pdfPage = pdf.AddPage()
graph = XGraphics.FromPdfPage(pdfPage)

Author:  kees50 [ Sat Jun 27, 2020 9:56 pm ]
Post subject:  Re: pagina toevoegen aan pdfsharp document

klopt het werk mu
Bedant

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/