Wes Gourh
Wes Gourh

Reputation: 69

How to open PDF in PDFsharp where PDF is added as a resource to the project

I'm getting an error in the path because it's retrieving System.Byte[] in it. How can I access the PDF which is added in my resources?

Code:

PdfDocument = PdfSharp.Pdf.IO.PdfReader.Open(My.Resources.CANEezz_Individual.ToString, PdfDocumentOpenMode.Modify)

Dim font9 As XFont = New XFont("Arial", 8)
Dim page As PdfPage = PdfDocument.Pages(0)
Dim graph As XGraphics = XGraphics.FromPdfPage(page)
graph.DrawString("Bank Passboook", font9, XBrushes.Black, 518, 343)

Dim pdfFilename As String = "something.pdf"
PdfDocument.Save(pdfFilename)
Process.Start(pdfFilename)

Upvotes: 3

Views: 3929

Answers (1)

Pass the byte[] to the constructor of MemoryStream and pass that memory stream to the PdfReader.Open() method.

Upvotes: 6

Related Questions