Display a pdf if a form. RRS feed

  • Question

  • I'm looking to have a form in which a grid displays names of pdf files. I would like to see the pdf file on the side of the grid. I'd like the pdf to refresh when doing a row change in the grid.

    My question: I know there are activeX to handle this - Do you guys recommend a specific activex or any other method to do this?

    I also use Foxypreviewer - but I don't think foxy can do that.

    Any recommendations would be appreciated.

    Friday, September 13, 2019 3:25 AM

All replies

  • Hi Aleniko2,

    this can be done by placing an Internet Explorer ole object on your form and assigning the pdf to it like this:

    * // This code converts a simple path/file reference
    * // into a valid URI that can be used within a browser
    m.myFile = myCursor.myPDFfilename
    DECLARE INTEGER UrlCreateFromPath in Shlwapi.dll ;
    	STRING @Filename , ;
    	STRING @FileURI , ;
    	INTEGER @nSize , ;
    	INTEGER nFlags
    LOCAL liSize as Integer, lcUri as String, liHResult as Integer
    liSize    = LEN( m.myFile ) + 50
    lcUri     = PADR( m.myFile , liSize , [ ] )
    liHResult = UrlCreateFromPath( m.myFile , @lcURI , @liSize , 0 )
    m.myFile  = lcUri
    Thisform.oleBrowserObj.Navigate( m.myFile )

    I use this code in the app I posted a hardcopy from in a previous post about ribbons (click here).

    In that form I use the OLE browser object to take care of displaying the pdfs. Reason for this is, that absolutely every PDF viewer registers itself for use in browsers. Therefore you don't have to study their ole interfaces at all. You only need the browser to do the job ;)

    However, there are some little nasty twirks with browsers, you will have to take care of. One of those is handled in a blogpost. It's about deleting files that are currentliy shown in a browser. If this happens in your app, then you should have a look here. Though, the post is in german, there is a combobox to the right where you can get a (more or less readable) translation to another language.


    Gruss / Best regards
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible,
    you are, by definition, not smart enough to debug it. 010101100100011001010000011110000101001001101111011000110110101101110011

    Friday, September 13, 2019 6:12 AM
  • Thanks alot.

    actually the file conversion wasnt working - I just used fillpath of the filename and it works.

    Monday, September 16, 2019 2:48 AM
  • Thanks alot.

    actually the file conversion wasnt working - I just used fillpath of the filename and it works.


    Is your problem solved? If so, please mark the useful replies as answers.  

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 16, 2019 5:31 AM