Results 1 to 8 of 8

Thread: Show PDF [Resolved]

  1. #1

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    Resolved Show PDF [Resolved]

    Hi,
    How can I show a PDF from vb.net form?
    Last edited by haihems; May 2nd, 2005 at 11:22 PM.
    Think Before Ink

    Visual Studio .NET 2002/.NET Framework 1.0

  2. #2
    Member
    Join Date
    Sep 2004
    Posts
    52

    Re: Show PDF

    Code:
     Process.Start("H:\Jetway Manual.pdf")
    This form of code assumes that there is the standard file association between Adobe Acrobat and .pdf file extensions and will fire up Acrobat and show the named file.
    Last edited by XTab; Apr 29th, 2005 at 08:39 AM.

  3. #3
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: Show PDF

    if you have the full version of adobe acrobat installed, then you will be able to use the PDF ActiveX control that comes with it.
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Show PDF

    Quote Originally Posted by tr333
    if you have the full version of adobe acrobat installed, then you will be able to use the PDF ActiveX control that comes with it.
    Not quite true, if you have Acrobat Reader you can use the pdf.ocx to display a pdf on a form, etc. depending on
    how much control you want over it you may still have to use the full version though.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    Unhappy Re: Show PDF

    Hi,
    Thanks for your response. i did the following and it works.
    VB Code:
    1. Dim pdfProcess As Process
    2.  pdfProcess = pdfProcess.Start("AcroRd32.exe", "c:\temp\a.pdf")

    I've one more doubt. I hope the exe names for Acrobat will change like 'AcroRd32.exe' , 'Acro32.exe' etc., for different windows version. So how can I know the name of Acrobat's exe file in client' machine?

    Or straightly can i give
    pdfProcess= pdfProcess.Start("c:\temp\a.pdf")
    to open the pdf straightly.

    If there is no acrobat reader in clinet's machine , how can i track it???

    Regards,
    Hems.
    Think Before Ink

    Visual Studio .NET 2002/.NET Framework 1.0

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Show PDF

    Here is a way to get the associated program with the .pdf extension. Note, if the users system has another
    program instead of Acrobat to open .pdf files then it will get that program and not Arobat.

    VB Code:
    1. Option Explicit On
    2.  
    3. Imports System.IO
    4.  
    5. Public Module Module1
    6.  
    7.     Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, _
    8.     ByVal lpDirectory As String, ByVal lpResult As String) As Integer
    9.  
    10.     Public Sub FindAcrobat(ByVal strRunMe As String)
    11.         Try
    12.             'CREATE SOME VARIABLES
    13.             Dim PDFExec As String = New String(" "c, 255)
    14.             Dim strFileName As String
    15.             Dim lRet As Long
    16.             Dim SWriter As StreamWriter
    17.             'CREATE A TEMP PDF FILE SO WE CAN FIND OUT WHERE THE LOCATION IS ONE ON THE SYSTEM
    18.             strFileName = Application.StartupPath & "\temp.pdf"
    19.             SWriter = File.CreateText(strFileName)
    20.             SWriter.Write("1")
    21.             SWriter.Close()
    22.             'CALL THE API TO FIND THE EXE ASSOCIATED WITH MOV FILES
    23.             lRet = FindExecutable(strFileName, vbNullString, PDFExec)
    24.             PDFExec = PDFExec.Trim
    25.             'IF WE GET ONE, LAUNCH THE PDF IN A NEW INSTANCE OF ACROBAT
    26.             If lRet <= 32 Or PDFExec = String.Empty Then
    27.                 MessageBox.Show("Could not find Acrobat")
    28.             Else
    29.                 Process.Start(PDFExec, strRunMe)
    30.             End If
    31.             'DELETE THAT PESKY TEMP FILE
    32.             File.Delete(strFileName)
    33.         Catch ex As Exception
    34.             'IF ANYTHING GOES WRONG, LET PEOPLE KNOW WHO'S FAULT IT IS
    35.             MessageBox.Show("An error has occured!" & ControlChars.CrLf & ex.Message)
    36.         End Try
    37.     End Sub
    38.  
    39. End Module
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    Re: Show PDF

    Thanks RobDog !!

    Sure, this is helpful for me !!!
    Think Before Ink

    Visual Studio .NET 2002/.NET Framework 1.0

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Show PDF

    I hope so, but I just modified a class klienma gave me to work for IE and made it work for Acrobat.
    So, I can only take partial credit.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width