Page 1 of 1

accessing a pdf file

Posted: Mon Dec 14, 2015 9:58 pm
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

Re: accessing a pdf file

Posted: Mon Dec 14, 2015 10:43 pm
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

Re: accessing a pdf file

Posted: Tue Dec 15, 2015 1:36 am
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.