How to open PDF files on Form1 from Resources RRS feed

  • Question

  • I am creating a small program and I want to open a PDF file in the form itself using a PDF Reader (COM Component), but I don't want to use an OpenFileDialog as my file is in my Resources and it's the only PDF that will be opened.

    How can I open this PDF directly on the PDF reader when I click a button?

    Friday, July 31, 2020 3:24 PM

All replies

  • You can extract the PDF to a temporary file
    For example, with a PDF in resources named "test1"

    Dim sPDFFile = My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData + "\testPDF.pdf"
    Dim bytePDFFile As Byte() = My.Resources.test1
    If bytePDFFile IsNot Nothing Then My.Computer.FileSystem.WriteAllBytes(sPDFFile, bytePDFFile, False)
    ' Test

    Friday, July 31, 2020 3:44 PM
  • Thank you for your reply Castorix31.

    It works, but this opens the computer installed PDF Reader.  In other words it leaves my program an it opens it externally.  What I want is to open my PDF file on my winform.

    Could you please help me with that?

    Sunday, August 2, 2020 12:33 AM
  • For example, with "Adobe Acrobat 7.0 Browser Control Type Library 1.0

    I had posted a sample in this thread

    Sunday, August 2, 2020 7:55 AM