Page 1 of 1

Webgadget as pdf-viewer?

Posted: Fri Mar 22, 2013 1:01 pm
by Hadrian
Is it possible to use PB-webgadget as a pdf-viewer?
How to open pdf-file in this gadget?

Re: Webgadget as pdf-viewer?

Posted: Fri Mar 22, 2013 1:34 pm
by Josh

Code: Select all

  Procedure NavigationCallback(Gadget, Url$) 
    If Url$= "http://www.purebasic.com/news.php" 
      MessageRequester("", "No news today!") 
      ProcedureReturn #False 
    Else 
      ProcedureReturn #True 
    EndIf 
  EndProcedure 
  
  If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
    WebGadget(0, 10, 10, 580, 280, "http://asw.gmxhome.de/PureBasicBuch.pdf") 
    SetGadgetAttribute(0, #PB_Web_NavigationCallback, @NavigationCallback())
    Repeat 
    Until WaitWindowEvent() = #PB_Event_CloseWindow 
  EndIf

Re: Webgadget as pdf-viewer?

Posted: Fri Mar 22, 2013 1:56 pm
by MachineCode
@Josh: That's unreliable. It opens in a PDF viewer on my PC, instead of in the browser. That's because people have different ways of default-viewing PDFs.

Re: Webgadget as pdf-viewer?

Posted: Fri Mar 22, 2013 1:59 pm
by luis
Keep in mind the way it will work depend on the user's settings.
For example I don't like PDFs to be opened inside the browser, and I set it to launch the PDF viewer instead.
So the code above in my case open the PDF outside the browser.

EDIT: too late.

Re: Webgadget as pdf-viewer?

Posted: Fri Mar 22, 2013 11:52 pm
by Hadrian
Thank you guys.
On my computer I disabled IE and use Firefox as browser and Foxit as pdf-reader.
When I execute Josh's code then I get a pdf-viewer inside the webgadget.
But I agree Luis to launch a viewer outside the gadget.
Anyway I shall continue with experimenting the interesting webgadget. :D

Re: Webgadget as pdf-viewer?

Posted: Sat Mar 23, 2013 7:45 am
by Little John
Hadrian wrote:On my computer I disabled IE and use Firefox as browser and Foxit as pdf-reader.
When I execute Josh's code then I get a pdf-viewer inside the webgadget.
Since the current Firefox version has a built-in PDF viewer, it should work fine even without any additional program, I think.

Re: Webgadget as pdf-viewer?

Posted: Sat Mar 23, 2013 7:55 am
by MachineCode
Little John wrote:Since the current Firefox version has a built-in PDF viewer, it should work fine even without any additional program, I think.
Which would be fine if Firefox were the only browser in existence. But what about IE, Chrome, Safari, Opera, and so on?

Re: Webgadget as pdf-viewer?

Posted: Sat Mar 23, 2013 7:59 am
by Little John
MachineCode wrote:But what about IE, Chrome, Safari, Opera, and so on?
Little John wrote:
Hadrian wrote:On my computer I disabled IE and use Firefox as browser and Foxit as pdf-reader.
When I execute Josh's code then I get a pdf-viewer inside the webgadget.
Since the current Firefox version has a built-in PDF viewer, it should work fine even without any additional program, I think.
I quoted Hadrian's post, and just refered to what happens on his computer.

Re: Webgadget as pdf-viewer?

Posted: Sat Mar 23, 2013 8:14 am
by MachineCode
So you did. I overlooked that fact. Sorry.