locked
Store and Open pdf in Visual Basic RRS feed

  • Question

  • I have added a pdf into Solution Explorer for an application I am writing. When a user clicks on the help button on the menu strip, I want it to open this pdf file. When the solution is built, I want the pdf to be part of it so that I won't have to specify a location. Is this possible in Visual Basic?

    Saturday, December 24, 2016 1:01 PM

Answers

  • This code shows how to open a pdf in adobe reader. The pdf is installed in the application folder along with the program.

        Private Sub PDFManualToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PDFManualToolStripMenuItem.Click
            Dim NewName As String = StartupDir$ + "Cadrail Manual.pdf"
    
            If File.Exists(NewName) Then
                System.Diagnostics.Process.Start(NewName)
            Else
                MsgBox("Cadrail cannot find the file: " + Chr(13) + Chr(13) + NewName + Chr(13) + Chr(13) + "The file may have been moved.", 48, "Open Manual PDF")
            End If
    
        End Sub


    PS Here is how to get the program folder:

            StartupDir$ = System.Windows.Forms.Application.StartupPath



    • Edited by tommytwotrain Saturday, December 24, 2016 1:44 PM
    • Proposed as answer by Frank L. Smith Tuesday, December 27, 2016 3:51 PM
    • Marked as answer by RNDN Tuesday, December 27, 2016 9:27 PM
    Saturday, December 24, 2016 1:38 PM
  • I've not used Solution Explorer for that but I suppose that method may work.

    Typically I select the Project tab and at the bottom select the applications properties menu item. In the applications properties window I select Resources, then in the add dropdown I select Add from existing file. Then browse to the file and add it. Then build the app and it becomes part of the applications executable file.

    Then it is available from My.Resources.

    However to display it I use the Adobe Acrobat Reader ActiveX control that comes with Adobe Acrobat Reader. So if you have a current version of Adobe Acrobat Reader installed on your system you can use that control to display the .PDF.

    But the ActiveX control can only load from a File. So you need to write the resource to a File prior to loading it. You can get a temporary file name to use for that. Write the resource to the temp file then have the ActiveX load it. As in the Button2 click sub in the below code.

    You could also add a Dialog to your app and place the Adobe control on the Dialog for doing this so a Dialog is launched displaying the .PDF and the Dialog could get the file path from its parent Form for the .PDF file.

    Also the Adobe Reader ActiveX seems the app is required to be compiled to x86 unless that has been changed since I tested it last and I don't have the current Adober Reader installed.

    So if you download and install Adobe Reader then you will need to add it to the ToolBox using the ToolBox manager and I believe it will be a Com component.

    Plus after adding it to a project and building the project you should then go into the applications properties, references, and click on the references for Adobe to get their properties and set output to local or whatever it says so the .Dlls will be copied to the bin/debug or bin/release folder of your app. So if you decide to install your app on another system you can provide the .Dll's with it required by the ActiveX control or the ActiveX control will not work on another system especially if the other system doesn't have Adobe Reader installed on it.

    This code I dynamically create the Adobe ActiveX because I didn't drag a copy of it from the ToolBox onto the Form but that is not required.

    Option Strict On
    
    ' Has to be compiled to x86 CPU due to currently using 32 bit .Dll for AAR control.
    
    Imports AcroPDFLib
    Imports AxAcroPDFLib
    
    Public Class Form1
    
        WithEvents AxAcroPDF1 As New AxAcroPDFLib.AxAcroPDF
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))
            With AxAcroPDF1
                .Location = New Point(0, Button1.Bottom + 5)
                .Width = Me.ClientRectangle.Width
                .Height = Me.ClientRectangle.Height - (Button1.Bottom + 5)
            End With
            Me.Controls.Add(AxAcroPDF1)
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Using OFD As New OpenFileDialog
                With OFD
                    .Filter = "PDF files (*.PDF)|*.PDF"
                    .InitialDirectory = "C:\Users\John\Desktop"
                    .Multiselect = False
                    .Title = "Load PDF file into AxAcroPDF1"
                End With
                If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
                    AxAcroPDF1.LoadFile(OFD.FileName)
                End If
            End Using
        End Sub
    
        Private Sub AxAcroPDF1_OnError(sender As Object, e As EventArgs)
    
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim TempFile As String = IO.Path.GetTempFileName
            My.Computer.FileSystem.WriteAllBytes(TempFile, My.Resources.AVI_File_Format, False)
            AxAcroPDF1.LoadFile(TempFile)
        End Sub
    
    End Class
    


    La vida loca

    • Marked as answer by RNDN Tuesday, December 27, 2016 9:26 PM
    Saturday, December 24, 2016 6:34 PM
  • I place a zip folder of a new project which as a Form and a Dialog.

    The Dialog has the AxAcroPDF1 control on it.

    When the app launches the Form writes an embedded resource PDF file to disk using a temp file name.

    When the Dialog is shown its AxAcroPDF1 control loads the File which the Form wrote to disk when the app originally launched.

    Below is the link to download the project from my onedrive. If you do not have Visual Studio 2012 or later you will not be able to open the project.

    https://1drv.ms/u/s!Ag0nb6dfIqu4gh7X18iNXBcsQriC


    La vida loca

    • Edited by Mr. Monkeyboy Saturday, December 24, 2016 9:45 PM
    • Marked as answer by RNDN Tuesday, December 27, 2016 9:26 PM
    Saturday, December 24, 2016 9:43 PM
  • I have added a pdf into Solution Explorer for an application I am writing. When a user clicks on the help button on the menu strip, I want it to open this pdf file. When the solution is built, I want the pdf to be part of it so that I won't have to specify a location. Is this possible in Visual Basic?

    One way you might consider is to not include it where you are, but rather put it in the resources. I'll assume that it's not a large file or if it is, consider putting it into your program's installer instead.

    I grabbed a PDF file and renamed it for this example, then in the program's properties, I added it as a resource:

    I set up a pretty simple little class called "Utilities" to make all of this easier:

    Option Strict On Option Explicit On Option Infer Off Imports System.IO Imports System.IO.Path Imports System.Environment Public NotInheritable Class Utilities Private Sub New() End Sub Public Shared ReadOnly ProgramDataFolderPath As String = _ Combine(GetFolderPath(SpecialFolder.ApplicationData), _ My.Application.Info.AssemblyName) Public Shared ReadOnly Property HelpFilePath As String Get Return Combine(ProgramDataFolderPath, "Help.pdf") End Get End Property Public Shared ReadOnly Property HelpFileExists As Boolean Get Return File.Exists(HelpFilePath) End Get End Property Public Shared Sub CreateProgramDataFolder() Try Dim di As New DirectoryInfo(ProgramDataFolderPath) If Not di.Exists Then di.Create() End If Catch ex As Exception Throw End Try End Sub Public Shared Sub WriteHelpFile(Optional ByVal overwriteIfExists As Boolean = False) Try Dim proceed As Boolean = False If Not HelpFileExists Then proceed = True Else If overwriteIfExists Then proceed = True End If End If If proceed Then CreateProgramDataFolder() File.WriteAllBytes(HelpFilePath, My.Resources.ProgramHelp) End If Catch ex As Exception Throw End Try End Sub End Class


    To test it (which worked), this is what I used in Form1:

    Option Strict On Option Explicit On Option Infer Off Public Class Form1 Private Sub Form1_Load(sender As System.Object, _ e As System.EventArgs) _ Handles MyBase.Load ExtractHelpFile() End Sub Private Sub ExtractHelpFile() Try Utilities.WriteHelpFile() OpenHelpFile() Catch ex As Exception MessageBox.Show(String.Format("An error occurred:{0}{0}{1}", _ vbCrLf, ex.Message), _ "Exception Thrown", _ MessageBoxButtons.OK, _ MessageBoxIcon.Warning) End Try End Sub Private Sub OpenHelpFile() Try If Utilities.HelpFileExists Then Process.Start(Utilities.HelpFilePath).WaitForExit() End If Catch ex As Exception MessageBox.Show(String.Format("An error occurred:{0}{0}{1}", _ vbCrLf, ex.Message), _ "Exception Thrown", _ MessageBoxButtons.OK, _ MessageBoxIcon.Warning) End Try End Sub End Class


    I'm relying on the user to have *some* PDF reader which is very likely the case. If, however, you want to look at third-party stuff, consider DevExpress:

    https://www.devexpress.com/Products/NET/Controls/WinForms/PDF-Viewer/

    I hope that helps. :)


    "One who has no vices also has no virtues..."

    • Marked as answer by RNDN Tuesday, December 27, 2016 9:30 PM
    Tuesday, December 27, 2016 3:50 PM

All replies

  • This code shows how to open a pdf in adobe reader. The pdf is installed in the application folder along with the program.

        Private Sub PDFManualToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PDFManualToolStripMenuItem.Click
            Dim NewName As String = StartupDir$ + "Cadrail Manual.pdf"
    
            If File.Exists(NewName) Then
                System.Diagnostics.Process.Start(NewName)
            Else
                MsgBox("Cadrail cannot find the file: " + Chr(13) + Chr(13) + NewName + Chr(13) + Chr(13) + "The file may have been moved.", 48, "Open Manual PDF")
            End If
    
        End Sub


    PS Here is how to get the program folder:

            StartupDir$ = System.Windows.Forms.Application.StartupPath



    • Edited by tommytwotrain Saturday, December 24, 2016 1:44 PM
    • Proposed as answer by Frank L. Smith Tuesday, December 27, 2016 3:51 PM
    • Marked as answer by RNDN Tuesday, December 27, 2016 9:27 PM
    Saturday, December 24, 2016 1:38 PM
  • I've not used Solution Explorer for that but I suppose that method may work.

    Typically I select the Project tab and at the bottom select the applications properties menu item. In the applications properties window I select Resources, then in the add dropdown I select Add from existing file. Then browse to the file and add it. Then build the app and it becomes part of the applications executable file.

    Then it is available from My.Resources.

    However to display it I use the Adobe Acrobat Reader ActiveX control that comes with Adobe Acrobat Reader. So if you have a current version of Adobe Acrobat Reader installed on your system you can use that control to display the .PDF.

    But the ActiveX control can only load from a File. So you need to write the resource to a File prior to loading it. You can get a temporary file name to use for that. Write the resource to the temp file then have the ActiveX load it. As in the Button2 click sub in the below code.

    You could also add a Dialog to your app and place the Adobe control on the Dialog for doing this so a Dialog is launched displaying the .PDF and the Dialog could get the file path from its parent Form for the .PDF file.

    Also the Adobe Reader ActiveX seems the app is required to be compiled to x86 unless that has been changed since I tested it last and I don't have the current Adober Reader installed.

    So if you download and install Adobe Reader then you will need to add it to the ToolBox using the ToolBox manager and I believe it will be a Com component.

    Plus after adding it to a project and building the project you should then go into the applications properties, references, and click on the references for Adobe to get their properties and set output to local or whatever it says so the .Dlls will be copied to the bin/debug or bin/release folder of your app. So if you decide to install your app on another system you can provide the .Dll's with it required by the ActiveX control or the ActiveX control will not work on another system especially if the other system doesn't have Adobe Reader installed on it.

    This code I dynamically create the Adobe ActiveX because I didn't drag a copy of it from the ToolBox onto the Form but that is not required.

    Option Strict On
    
    ' Has to be compiled to x86 CPU due to currently using 32 bit .Dll for AAR control.
    
    Imports AcroPDFLib
    Imports AxAcroPDFLib
    
    Public Class Form1
    
        WithEvents AxAcroPDF1 As New AxAcroPDFLib.AxAcroPDF
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))
            With AxAcroPDF1
                .Location = New Point(0, Button1.Bottom + 5)
                .Width = Me.ClientRectangle.Width
                .Height = Me.ClientRectangle.Height - (Button1.Bottom + 5)
            End With
            Me.Controls.Add(AxAcroPDF1)
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Using OFD As New OpenFileDialog
                With OFD
                    .Filter = "PDF files (*.PDF)|*.PDF"
                    .InitialDirectory = "C:\Users\John\Desktop"
                    .Multiselect = False
                    .Title = "Load PDF file into AxAcroPDF1"
                End With
                If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
                    AxAcroPDF1.LoadFile(OFD.FileName)
                End If
            End Using
        End Sub
    
        Private Sub AxAcroPDF1_OnError(sender As Object, e As EventArgs)
    
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim TempFile As String = IO.Path.GetTempFileName
            My.Computer.FileSystem.WriteAllBytes(TempFile, My.Resources.AVI_File_Format, False)
            AxAcroPDF1.LoadFile(TempFile)
        End Sub
    
    End Class
    


    La vida loca

    • Marked as answer by RNDN Tuesday, December 27, 2016 9:26 PM
    Saturday, December 24, 2016 6:34 PM
  • Thanks for that. I copied your code and I got a couple of errors. StartupDir$ is not declared. File is not declared. I am new to VB so not sure how to proceed. Will this work if I have the pdf in the solution explorer?

    Saturday, December 24, 2016 7:50 PM
  • Thanks for that. I am trying to avoid OpenFileDialog. That is one reason I copied the pdf to the Solution Explorer but not sure how to reference it. I have Adobe PDF Reader added in the toolbox. I was wondering if I can use something like AxAcroPDF1.src to reference the pdf in the Solution Explore but as I am new to Visual Basic, I find it difficult to understand how to do it.
    Saturday, December 24, 2016 7:56 PM
  • Thanks for that. I am trying to avoid OpenFileDialog. That is one reason I copied the pdf to the Solution Explorer but not sure how to reference it. I have Adobe PDF Reader added in the toolbox. I was wondering if I can use something like AxAcroPDF1.src to reference the pdf in the Solution Explore but as I am new to Visual Basic, I find it difficult to understand how to do it.

    I believe I explained in my post how I did it. And I believe I mentioned the code in Button2 click sub and not the code in Button1 click sub.

    If you re-read my post which part can you not understand?


    La vida loca

    Saturday, December 24, 2016 9:09 PM
  • I place a zip folder of a new project which as a Form and a Dialog.

    The Dialog has the AxAcroPDF1 control on it.

    When the app launches the Form writes an embedded resource PDF file to disk using a temp file name.

    When the Dialog is shown its AxAcroPDF1 control loads the File which the Form wrote to disk when the app originally launched.

    Below is the link to download the project from my onedrive. If you do not have Visual Studio 2012 or later you will not be able to open the project.

    https://1drv.ms/u/s!Ag0nb6dfIqu4gh7X18iNXBcsQriC


    La vida loca

    • Edited by Mr. Monkeyboy Saturday, December 24, 2016 9:45 PM
    • Marked as answer by RNDN Tuesday, December 27, 2016 9:26 PM
    Saturday, December 24, 2016 9:43 PM
  • Thanks for that. I am trying to avoid OpenFileDialog. That is one reason I copied the pdf to the Solution Explorer but not sure how to reference it. I have Adobe PDF Reader added in the toolbox. I was wondering if I can use something like AxAcroPDF1.src to reference the pdf in the Solution Explore but as I am new to Visual Basic, I find it difficult to understand how to do it.

    I see. Well sorry it is just pieces of code that have to be assembled. I made a full working example below.

    Perhaps you should explain what your overall goal is in more detail. Why do you want to show a pdf file? Why solution explorer?

    If something is not declared then you should declare it. :) Just look up how to do that. Part of learning to program is learning to use the instructions and solve problems. 

    I guess I threw a bit of a curve with StartupDir$ you dont need the
    $ that is old. Just declare it a string.

           dim mypath as string.

    Its just a string that is the path to the file. This path is defined by where you application.exe is running from:

           System.Windows.Forms.Application.StartupPath

    You ask windows for the folder path to your exe. You put the pdf in that folder.

    You don't event need that string as I show in the example.

    As far as file.exits goes, you need to add a reference for it. If you put Option Strict On as the first line of code in the project form it will flag errors. See where I added Option Strict below. And now there is a red line under file. Put the mouse pointer over the red line and the error message will pop up. On the msg is show suggestions click that:

    after clicking a new popup with the suggestions. At the top is add File.IO click that:

    and the designer will add it to the top of your form as in the example. I also just removed the StartupDir$ variable. So you should be able to change the file name you yours and put the pdf in you \bin\debug folder and it will find it. Or hardcode in a path to your file just to test the rest of the code.

    Option Strict On
    
    Imports System.IO
    
    Public Class Form3
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim NewName As String = System.Windows.Forms.Application.StartupPath + "MyFile.pdf"
    
            If File.Exists(NewName) Then
                System.Diagnostics.Process.Start(NewName)
            Else
                MsgBox("Cadrail cannot find the file: " + Chr(13) + Chr(13) + NewName + Chr(13) + Chr(13) + "The file may have been moved.", MsgBoxStyle.OkOnly, "Open Manual PDF")
            End If
        End Sub
    End Class


    PS All of these things are complicated and complex. You have learning to do. Take each one step at a time. Get it working and understood then move to the next. Use the instructions. Then come back.
    Saturday, December 24, 2016 11:48 PM
  • You can take a look at this PDF Viewer which allows viewing PDFs from WinForm Applications. It supports to load PDFs both from file and from stream. Apart from viewing, other functions such as printing and exporting to image are supported as well. Besides, it's a independent library, means that users can also display PDF files successfully if they don't have Adobe installed on their system.
    • Edited by Jamesbn Monday, December 26, 2016 2:19 AM
    Monday, December 26, 2016 2:18 AM
  • I have added a pdf into Solution Explorer for an application I am writing. When a user clicks on the help button on the menu strip, I want it to open this pdf file. When the solution is built, I want the pdf to be part of it so that I won't have to specify a location. Is this possible in Visual Basic?

    One way you might consider is to not include it where you are, but rather put it in the resources. I'll assume that it's not a large file or if it is, consider putting it into your program's installer instead.

    I grabbed a PDF file and renamed it for this example, then in the program's properties, I added it as a resource:

    I set up a pretty simple little class called "Utilities" to make all of this easier:

    Option Strict On Option Explicit On Option Infer Off Imports System.IO Imports System.IO.Path Imports System.Environment Public NotInheritable Class Utilities Private Sub New() End Sub Public Shared ReadOnly ProgramDataFolderPath As String = _ Combine(GetFolderPath(SpecialFolder.ApplicationData), _ My.Application.Info.AssemblyName) Public Shared ReadOnly Property HelpFilePath As String Get Return Combine(ProgramDataFolderPath, "Help.pdf") End Get End Property Public Shared ReadOnly Property HelpFileExists As Boolean Get Return File.Exists(HelpFilePath) End Get End Property Public Shared Sub CreateProgramDataFolder() Try Dim di As New DirectoryInfo(ProgramDataFolderPath) If Not di.Exists Then di.Create() End If Catch ex As Exception Throw End Try End Sub Public Shared Sub WriteHelpFile(Optional ByVal overwriteIfExists As Boolean = False) Try Dim proceed As Boolean = False If Not HelpFileExists Then proceed = True Else If overwriteIfExists Then proceed = True End If End If If proceed Then CreateProgramDataFolder() File.WriteAllBytes(HelpFilePath, My.Resources.ProgramHelp) End If Catch ex As Exception Throw End Try End Sub End Class


    To test it (which worked), this is what I used in Form1:

    Option Strict On Option Explicit On Option Infer Off Public Class Form1 Private Sub Form1_Load(sender As System.Object, _ e As System.EventArgs) _ Handles MyBase.Load ExtractHelpFile() End Sub Private Sub ExtractHelpFile() Try Utilities.WriteHelpFile() OpenHelpFile() Catch ex As Exception MessageBox.Show(String.Format("An error occurred:{0}{0}{1}", _ vbCrLf, ex.Message), _ "Exception Thrown", _ MessageBoxButtons.OK, _ MessageBoxIcon.Warning) End Try End Sub Private Sub OpenHelpFile() Try If Utilities.HelpFileExists Then Process.Start(Utilities.HelpFilePath).WaitForExit() End If Catch ex As Exception MessageBox.Show(String.Format("An error occurred:{0}{0}{1}", _ vbCrLf, ex.Message), _ "Exception Thrown", _ MessageBoxButtons.OK, _ MessageBoxIcon.Warning) End Try End Sub End Class


    I'm relying on the user to have *some* PDF reader which is very likely the case. If, however, you want to look at third-party stuff, consider DevExpress:

    https://www.devexpress.com/Products/NET/Controls/WinForms/PDF-Viewer/

    I hope that helps. :)


    "One who has no vices also has no virtues..."

    • Marked as answer by RNDN Tuesday, December 27, 2016 9:30 PM
    Tuesday, December 27, 2016 3:50 PM
  • I see. Well sorry it is just pieces of code that have to be assembled. I made a full working example below.

    Perhaps you should explain what your overall goal is in more detail. Why do you want to show a pdf file? Why solution explorer? ...

    The confusion was created by StartupDir$. I thought it must be a reserved a special keyword and I was trying to resolve it. It didn't occur to me it was just something I had to declare. Everything is sorted now and it is working. The only change I had to do was to add a '\' in front of "MyFile.pdf"

    My application captures user information using Windows Forms and writes to a table in a SQL database. The user can also change or delete records. I have completed all that. Then I wrote the user guide and was thinking of an easy way the user can access it. With my limited knowledge on VB, I thought if I have the user guide in the solution explorer, then it will get compiled with the code so that I don't have to keep it in a folder. I don't know if this is feasible so I wanted to try that.

    I couldn't think of a better or easier way to include the User Guide. I thought of creating a .chm file and attach it to the Help button. But felt it was old fashioned. Couldn't bother to create new form for the user guide because every time I change the user guide, then I will have to change the form. That's why I thought of an easier way came up with having the pdf in the solution explorer.

    Thanks for your help.

    Tuesday, December 27, 2016 8:10 PM
  • I place a zip folder of a new project which as a Form and a Dialog.

    The Dialog has the AxAcroPDF1 control on it.

    When the app launches the Form writes an embedded resource PDF file to disk using a temp file name.

    ...


    La vida loca

    Yes, I understand this now. This is the kind of solution I was looking for. I downloaded your example, and that was easy to follow. Thanks for your help.

    Tuesday, December 27, 2016 9:26 PM
  • One way you might consider is to not include it where you are, but rather put it in the resources. I'll assume that it's not a large file or if it is, consider putting it into your program's installer instead.

    I grabbed a PDF file and renamed it for this example, then in the program's properties, I added it as a resource:

    ...

    I hope that helps. :)


    "One who has no vices also has no virtues..."

    Yes, this was very useful. I am using a similar approach now. Thanks for your help.
    Tuesday, December 27, 2016 9:30 PM
  • I see. Well sorry it is just pieces of code that have to be assembled. I made a full working example below.

    Perhaps you should explain what your overall goal is in more detail. Why do you want to show a pdf file? Why solution explorer? ...

    The confusion was created by StartupDir$. I thought it must be a reserved a special keyword and I was trying to resolve it. It didn't occur to me it was just something I had to declare. Everything is sorted now and it is working. The only change I had to do was to add a '\' in front of "MyFile.pdf"

    My application captures user information using Windows Forms and writes to a table in a SQL database. The user can also change or delete records. I have completed all that. Then I wrote the user guide and was thinking of an easy way the user can access it. With my limited knowledge on VB, I thought if I have the user guide in the solution explorer, then it will get compiled with the code so that I don't have to keep it in a folder. I don't know if this is feasible so I wanted to try that.

    I couldn't think of a better or easier way to include the User Guide. I thought of creating a .chm file and attach it to the Help button. But felt it was old fashioned. Couldn't bother to create new form for the user guide because every time I change the user guide, then I will have to change the form. That's why I thought of an easier way came up with having the pdf in the solution explorer.

    Thanks for your help.


    RNDN,

    Ok I thanks for explaining.

    Well I use both chm and pdf and they are selected from the help menu on the main form this way.

    There are functions that will trim out the file name or folder and add or not the required "\" etc as I say it was cut from my code and it was made a while ago.

    IMHO there is no reason to be concerned about putting a file in your app folder and reading it. Why bother with resources then you have to recompile you say you want to avoid and etc. I think there are funny things about resources be sure you test it with a stand alone .exe as it may not behave the same as it does in the VS IDE etc.

    Of course you have to include the files with your app but if you are not using an installer to install your app you don't have a real app.

    I would not use a 3rd party anything to show a pdf because they tend to be broken or bankrupt in a few years and anyway why bother in this case?

    My two bits I am sure others would disagree but I am not paid by the hour.

    PS I use the chm file to show a specific help topic when customer rmb clicks a button etc. Cant do much with pdf other than launch the entire doc in adobe reader unless you go with other things.

    Tuesday, December 27, 2016 10:58 PM
  • I think there are funny things about resources be sure you test it with a stand alone .exe as it may not behave the same as it does in the VS IDE etc.

    I don't know where you're getting that but you're as wrong as can be.

    The contents of the resources (whether it's pictures, sounds, or in this case a Portable Document file) is compiled into the program's executable - whether that's the \release or the \debug version, it's in there.

    I would not use a 3rd party anything to show a pdf because they tend to be broken or bankrupt in a few years...

    Then you've never used DevExpress...

    Cant do much with pdf other than launch the entire doc in adobe reader unless you go with other things.

    You can with a good reader (like the one from DevExpress) if the source supports anchors. I didn't suggest it capriciously and please do note that I offered it as an alternative.


    "One who has no vices also has no virtues..."



    Wednesday, December 28, 2016 2:14 AM