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.
- You are here:
- Home
- Q&A
- Q&A
- PowerBuilder
- Open file to view
- Tracy Lamb
- PowerBuilder
- Sunday, 1 July 2018 17:02 PM UTC
- Sunday, 1 July 2018 19:57 PM UTC
- PowerBuilder
- # 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
- Friday, 13 July 2018 16:40 PM UTC
- PowerBuilder
- # 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
- Sunday, 1 July 2018 18:18 PM UTC
- PowerBuilder
- # 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.
- jalil Rehman
- Thursday, 23 May 2024 23:39 PM UTC
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 ?
-
Helpful Loading... Helpful 0
- John Fauss
- Friday, 24 May 2024 13:21 PM UTC
-
Helpful Loading... Helpful 0
- jalil Rehman
- Tuesday, 28 May 2024 16:12 PM UTC
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
-
Helpful Loading... Helpful 0
- Page :
- 1
However, you are not allowed to reply to this question.
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