• After more than 30 years running websites and forums I am retiring.

    I have made many friends through the years. I will cherish my time getting to know you. I wish you all the best. This was not an easy decision to make. The cost to keep the communities running has gotten to the point where it's just too expensive. Security certificates, hosting cost, software renewals and everything else has increased threefold. While costs are up ad revenue is down. It's no longer viable to keep things running.

    All sites will be turned off on Thursday 30 November 2023. If you are interested in acquiring any of the websites I own you can Email Schwarz Network.

How to open a pdf file for viewing in VS?


Apr 4, 2005
How can I open a pdf file for viewing in VS? I'm guessing I need a third party dll so any recommendations are welcome.

I tried searching the forum for "pdf" but the word is too short :(


Dec 14, 2006
Scappoose, OR, USA
Hi Joe, Jumpy,

Good news. The Free Adobe Reader Version 10x has reinstated the AcroPDF.dll ActiveX

Use ChooseItems and under COM select the above. If it does not show path to:
C:\Program Files\Common Files\Adobe\Acrobat\ActiveX\AcroPDF.dll

Tons of good stuff in the control. LoadFile, Viewing, Printing, Etc...
The only thing it does not do is create or edit PDF's directly. If you choose to show the toolbar it has a button that links to the web site that can create PDFs for you.

(See Attached Picture)


  • AcroPDF_Control.gif
    107.8 KB · Views: 26
Last edited:


Apr 4, 2005
Sample: Merging images and pdfs to a single pdf.

Thank you for the tip. This library works really well.

I scrathed up a small sample code that merges any image files or existing pdf files to a single pdf. I hope it helps someone to get started with the PDF#-library.

Visual Basic:
    Public Sub CreatePDF(ByVal DesnationFilePath As String, _
            ByVal SourceFiles As List(Of String), _
            ByVal CropArea As Rectangle)

        'Create a new PDF document
        Dim OutputDoc As PdfSharp.Pdf.PdfDocument = New PdfSharp.Pdf.PdfDocument
        OutputDoc.Info.Title = "Created with PDFsharp"

        'Add one image or PDF at a time
        For PageNumber As Integer = 0 To SourceFiles.Count - 1
            Dim SourceFilePath As String = SourceFiles(PageNumber)
            If LCase(IO.Path.GetExtension(SourceFilePath)) = ".pdf" Then
                AddPdf(OutputDoc, SourceFilePath, CropArea)
            Else 'Must be a picture
                AddPicture(OutputDoc, SourceFilePath, CropArea)
            End If


    End Sub

    Private Sub AddPicture(ByRef OutputDoc As PdfSharp.Pdf.PdfDocument, ByVal ImgPath As String, ByVal CropArea As Rectangle)

        'Create an empty page
        Dim page As PdfSharp.Pdf.PdfPage = OutputDoc.AddPage()

        'Draw image
        Dim gfx As PdfSharp.Drawing.XGraphics = PdfSharp.Drawing.XGraphics.FromPdfPage(page)
        Dim image As PdfSharp.Drawing.XImage
        If CropArea = Nothing Then
            Dim SourceImg As System.Drawing.Bitmap = Bitmap.FromFile(ImgPath)
            image = PdfSharp.Drawing.XImage.FromGdiPlusImage(SourceImg)
            Dim OriginalImage As Bitmap = Bitmap.FromFile(ImgPath)
            Dim CroppedImage As Image = OriginalImage.Clone(CropArea, OriginalImage.PixelFormat)
            image = PdfSharp.Drawing.XImage.FromGdiPlusImage(CroppedImage)
        End If
        page.Height = (image.PixelHeight * 0.0025) * 72.0 * 400.0 / image.VerticalResolution
        page.Width = (image.PixelWidth * 0.0025) * 72.0 * 400.0 / image.HorizontalResolution
        gfx.DrawImage(image, 0, 0)

    End Sub

    Private Sub AddPdf(ByRef OutputDoc As PdfSharp.Pdf.PdfDocument, ByVal PdfPath As String, ByVal CropArea As Rectangle)

        'Add one page at a time
        Dim InputDoc As PdfSharp.Pdf.PdfDocument = PdfSharp.Pdf.IO.PdfReader.Open(PdfPath, PdfSharp.Pdf.IO.PdfDocumentOpenMode.Import)
        For i As Integer = 0 To InputDoc.PageCount - 1

    End Sub


Jan 17, 2008
Also the way I did it was adding a webbrowser and in the navigate option yust enter the path and filename..

webbrowser1.navigate = "C:\Users\Luis\Desktop\1.pdf"
Top Bottom