accessing a pdf file

Just starting out? Need help? Post your questions and find answers here.
Clif
New User
New User
Posts: 3
Joined: Thu Jul 30, 2015 6:37 pm
Location: Milwaukee USA

accessing a pdf file

Post by Clif »

I am fairly new to PureBasic and I am using it to write some Engineering design software. Theses will be compiled first to run on Windows 7 Pro 64 bit and later be compiled to run on Windows XP Pro 32 bit and OS X 64 bit.

As a start I have been using PureBasic to update a 4200 line design utility that I wrote in Power Basic for DOS in 1991 and last revised in 1995. This was done as a learning process to use a known program with confirmed results to create an up-to-date windows program. The program has all of its modules running correctly and fully de-bugged. The last little par to add to finish it and move on to the larger project I need to do is to be able to open the .pdf of the user manual I wrote from the help menu. I have tried using various versions of the example with the RunProgram command information in the PureBasic reference manual / help file and the best I have been able to get is to have no syntax error but not open the pdf with the code part shown below:

Code: Select all

Case #Menu_Manual  
            MessageRequester("Manual", "PDF of user manual loaded here")  
            If RunProgram("SECTION V5.0 win64 UserManual.pdf")
              Debug "SECTION Manual running"
            Else
              Debug "SECTION Manual not running"
            EndIf
The pdf file is in the same folder as the source and compiled codes. If anyone has a suggestion, I would be appreciative.

Clif

__________________________________________________
Code tags added
14.12.2015
RSBasic
infratec
Always Here
Always Here
Posts: 7794
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: accessing a pdf file

Post by infratec »

Hi,

this works only if there is a default application for pdf files.

Next is: you need also the path like:

Code: Select all

RunProgram(GetPathPart(ProgramFilename()) + "SECTION V5.0 win64 UserManual.pdf")
To make this working also in the PB GUI, you need to enable the 'Create temporary executable in the source directory'
(see compiler options)

Bernd
User avatar
kpeters58
Enthusiast
Enthusiast
Posts: 341
Joined: Tue Nov 22, 2011 5:11 pm
Location: Kelowna, BC, Canada

Re: accessing a pdf file

Post by kpeters58 »

Alternatively you can use your browser (a PDF plugin must be installed for this to work, as well):

Code: Select all

If OpenWindow(0, #PB_Ignore, #PB_Ignore, 800, 600, "Help", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
  fname.s = "C:\t4-fill-14e.pdf"
  
  Browser = WebGadget(#PB_Any, 10, 10, 780, 580, "file://" + fname)
  If (Browser = 0)
    MessageRequester("Browser error", "The required browser component for your operating system was not found - please contact support.") 
  EndIf  
EndIf

Repeat: Until WaitWindowEvent() = #PB_Event_CloseWindow
If I could have decent working links/jumps to chapters with PDFs, I'd use them - I like the fact that it's a single file.

I have never had acceptable luck with such features from within my software, therefore I am now using HTML help files using the WebGadget. Years ago I spent a lot of money on "Help & Manual" and now also create PDFs from my help sources as well (in one go) which I provide for potential users who'd like to read up before installing a full blown demo.
PB 5.73 on Windows 10 & OS X High Sierra
Post Reply