Webgadget as pdf-viewer?

Just starting out? Need help? Post your questions and find answers here.
Hadrian
User
User
Posts: 11
Joined: Fri Nov 09, 2012 12:50 pm

Webgadget as pdf-viewer?

Post by Hadrian »

Is it possible to use PB-webgadget as a pdf-viewer?
How to open pdf-file in this gadget?
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Webgadget as pdf-viewer?

Post 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
sorry for my bad english
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Webgadget as pdf-viewer?

Post 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.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Webgadget as pdf-viewer?

Post 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.
"Have you tried turning it off and on again ?"
Hadrian
User
User
Posts: 11
Joined: Fri Nov 09, 2012 12:50 pm

Re: Webgadget as pdf-viewer?

Post 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
Little John
Addict
Addict
Posts: 4793
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Webgadget as pdf-viewer?

Post 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.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Webgadget as pdf-viewer?

Post 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?
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Little John
Addict
Addict
Posts: 4793
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Webgadget as pdf-viewer?

Post 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.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Webgadget as pdf-viewer?

Post by MachineCode »

So you did. I overlooked that fact. Sorry.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Post Reply