PDFSharp example

sahin kaya 20 Reputation points
2023-09-14T17:43:14.99+00:00

How can I add the pdf in D drive in the following code

Dim gfx As PdfSharp.Drawing.XGraphics
        Dim page As Pdf.PdfPage
        Dim size As PdfSharp.Drawing.XSize
        Dim font As PdfSharp.Drawing.XFont
        Dim path As PdfSharp.Drawing.XGraphicsPath
        Dim pen As PdfSharp.Drawing.XPen
        Dim pdfDoc As Pdf.PdfDocument

        page = New Pdf.PdfPage()
        page.Size = PdfSharp.PageSize.Letter

        pdfDoc = New Pdf.PdfDocument()
        pdfDoc.Pages.Add(page)
        'page = New Pdf.PdfPage("d:\a.pdf")

        gfx = PdfSharp.Drawing.XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend)
        size = gfx.MeasureString("sahin", font)

        gfx.TranslateTransform(3, 5)
        gfx.RotateTransform(5)
        gfx.TranslateTransform(2, 5)

        path.AddString("ss", font.FontFamily, XFontStyle.BoldItalic, 150, New XPoint(50, 55), XStringFormat.Default)

        pen = New XPen(XColor.FromArgb(128, 255, 0, 0), 2)

        gfx.DrawPath(pen, path)
Developer technologies | VB
{count} votes

2 answers

Sort by: Most helpful
  1. P a u l 10,761 Reputation points
    2023-09-14T18:34:58.9766667+00:00

    You'd call .Save() at the end, i.e.:

    pdfDoc.Save("d:\\a.pdf");
    
    0 comments No comments

  2. Olaf Helper 47,441 Reputation points
    2023-09-18T06:26:53.0766667+00:00

    Read first the documentation, ask the author or community at https://github.com/topics/pdfsharp

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.