1. Tracy Lamb
  2. PowerBuilder
  3. Sunday, 1 July 2018 17:02 PM UTC

How can I open a PDF file for viewing?  My db has a list of PDF files that are stored on the file system.  I'd like to provide the option for my users to open/view the file from my application instead of through the file system.

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Sunday, 1 July 2018 19:57 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Tracy;

  In addition to Andreas excellent answer .. another alternative is to host your PDF file(s) on a web server and then use PB's iNET object's HyperlinkToURL ( ) method to deliver the PDF to the user machine's web browser where your PB App is executing.

HTH

Regards ... Chris

Comment
  1. Tracy Lamb
  2. Friday, 13 July 2018 16:17 PM UTC
Thank you... I chose this way as it seems to be the easiest and most "fool proof". Here's what I did (straight from the manual):

GetContextService("Internet", iinet_base)

iinet_base.HyperlinkToURL(sle_url.text)



It doesn't open the PDF in Adobe Acrobat Reader, but I think this solution will be fine. Thanks again.

~~~Tracy
  1. Helpful
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Friday, 13 July 2018 16:40 PM UTC
  2. PowerBuilder
  3. # 1

Thank you for answering!  I tried the shellexecute(…) and it works great!  My only issue is that I don't know how to disable editing of any kind.  The documents my users will be viewing will all be "read only".  I'm guessing that if you have a version of Adobe Acrobat that allows editing, then the user would be able to make changes and save the document back to the same location.  That doesn't seem possible with the HyperlinkToURL() solution.

Again, thank you most kindly for taking the time to respond! Much appreciated.

~~~Tracy

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Sunday, 1 July 2018 18:18 PM UTC
  2. PowerBuilder
  3. # 2

Hi.

You can use the shellexecute win32 function. Here is the way to declare it:

FUNCTION long ShellExecute (uint ihwnd, string lpszOp, string lpszFile, string lpszParams, string lpszDir, int wShowCmd ) LIBRARY "Shell32.dll" ALIAS FOR "ShellExecuteW"

This is an example of using that function:

shellexecute(handle(this), "open", "c:\1.pdf", ls_null, ls_null, 0)

Of course before using it, you will have to save your pdf from db to some place in your hdd.

An alternative is to use Adobe Acrobat Browser ActiveX Control.

Andreas.

Comment
  1. jalil Rehman
  2. Thursday, 23 May 2024 23:39 PM UTC
Hi Andreas

This ShellExecute function does work for the 32 bit application but not work for the 64 bit application . Do I have to do something different for 64 bit ?
  1. Helpful
  1. John Fauss
  2. Friday, 24 May 2024 13:21 PM UTC
I notice that you created a new Q&A post to ask this question, Jalil, which is the right way to ask a new question. There are several responses to your question in that thread.
  1. Helpful
  1. jalil Rehman
  2. Tuesday, 28 May 2024 16:12 PM UTC
Hi John ,

yes I came across this post and post my question but no response so decided to put up as new Question

BTW I am very grateful for your explanation and other responses by the co-workers in that other post. really appreciate your guys time and effort .

Thanks very much . keep doing the good work
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.