Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1] 2
  Reply  |  Print  
Author Topic: Display PDF-Files in GDC  (Read 18422 times)
Stefan S.
Posts: 84


« on: April 12, 2016, 07:39:00 am »

Hello List,

I am looking for a way to display a PDF-File in a GDC-Window.
I want not open the file with a PDF-Viewer, or convert the pages in a JPEG-Format.
It must be possible to "browse" through the File.
I tried to use the Integrated-Browser Function of the GDC. But this is not working.

Has anybody done something like this before?
Thanks in advance.


Stefan Serwe


Lionel F.
Four Js
Posts: 82


« Reply #1 on: April 12, 2016, 11:23:05 am »

Hi Stefan,

From a Support point of view, I would highly recommend to use a launchurl frontcall which is fully compatible with all front-ends and which will open the PDF file with the program associated to the PDF extension on the client workstation.

Concerning using PDF files inside integrated browser or else a webcomponent (integrated browser in deprecated in GDC v3, it's better to use an URL-based webcomponent), this is a solution I would not recommend. As mentioned in the documentation (https://4js.com/online_documentation/fjs-fgl-manual-html/?path=fjs-fgl-manual#c_fgl_webcomponent_intro.html), webcomponents may have limitations as they are implemented with a "webview" widget, which is not a full-featured web browser.

So for the GDC, it highly depends on the default PDF viewer installed on the workstation: some of them might be supported by the webview, some others might not. But this is something whereon we don't have control.

Best regards,
Lionel

Reuben B.
Four Js
Posts: 949


« Reply #2 on: April 12, 2016, 12:25:46 pm »

This topic did come up during the Genero 3.0 EAP.  I think Snorri mentioned he had some success incorporating PDF.js https://github.com/mozilla/pdf.js/blob/master/README.md into a WebComponent.

Reuben 

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Stefan S.
Posts: 84


« Reply #3 on: April 13, 2016, 08:37:09 am »

Helo,

thanks.
I'm not sure if I understand pdf.js correctly.
I read that it is standard PDF-Viewer in firefox.
So I installed Firefox, and tried to display the PDF File to a webcomponent Field.
But it doesn't work.
I tired to wirte a littel html File with an included PDF-Object, but this is not working too.....

Stefan Serwe

Snorri B.
Posts: 103


« Reply #4 on: April 13, 2016, 11:46:51 am »

Hi.

I have successfully implemented view of PDF files in Genero v3.0. It was impossible in prior versions unless you converted each page to an image. I use the PDF.js viewer from Mozilla. To view your files you have to install it on your webserver.

Here is code and a form that will allow you to see how this works. Save the 4gl to main.4gl and the form to form.per, compile and then you can try it out:

$  fglrun main http://mozilla.github.io/pdf.js/web/viewer.html

Then you can enter any url to see the capabilities.

main.4gl:

DEFINE browser, url STRING

MAIN

let url = arg_val(1)
OPEN WINDOW w WITH FORM "form"
let browser=url
while true
  INPUT BY NAME url, browser  without defaults attributes(unbuffered)
    on action exit exit program
    after field url
      if url is null then next field url end if
      let browser=url
   END INPUT
end while
close window w
END MAIN

form.per:
LAYOUT
GRID
{
Enter url:[e1                                  ]


[browser                                                                             ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
[                                                                                    ]
}
END --GRID
END --LAYOUT

ATTRIBUTES

WEBCOMPONENT browser=FORMONLY.browser
   , STRETCH=BOTH
                   ;
EDIT e1=formonly.url type varchar, scroll;
END --ATTRIBUTES

I hope this helps,
-Snorri
 
Stefan S.
Posts: 84


« Reply #5 on: April 13, 2016, 12:17:29 pm »

Hello Snorri,

thanks, but can you give me a tip how to install pdf.js ?
What do you mean: "install it on your webserver" ?
Have I to install pdf.js on every client ?


Stefan
Snorri B.
Posts: 103


« Reply #6 on: April 13, 2016, 12:30:48 pm »

Hi Stefan.

You need a webserver, like apache running.

To download pdf.js go here: https://mozilla.github.io/pdf.js/getting_started/#download

And download the stable version. Follow the instructions there.

You don't need to install ANYTHING on the clients, that's the beauty of it.

Regards,
-Snorri

Leo S.
Four Js
Posts: 119


« Reply #7 on: April 13, 2016, 01:04:20 pm »

Stefan, are you on 2.50 or 3.00 ?
In principle you don't need necessarily apache installed somewhere.
Webcomponents do work without apache in GDC , but in GDC2.50 the automatic deployment of webcomponents is a bit tricky.
(via GAS there is a special location, without GAS there is a special frontcall CALL("standard","setwebcomponentpath",[location],[] which allows you to fgl_putfile the component somewhere to your client and inform GDC where to find it)
In GDC3.00 (assuming then also a 3.00 runtime) webcomponents can be at the same location as the program location and are automatically deployed to the GDC , no matter if the GDC runs via GAS or in direct/ssh mode.
So tell me your version and I'll try to assemble a sample.
Regards, Leo
Snorri B.
Posts: 103


« Reply #8 on: April 13, 2016, 01:17:40 pm »

I you want to use PDF.js, you definitely need a webserver. You also need to put the file you want to display somewhere in the webservers document directory. For example, when I display a PDF file in GDC through PDF.js the url looks something like:

http://MY_SERVER/pdfview/web/viewer.html?file=../../FILES/filename.pdf

Regards,
-Snorri
Stefan S.
Posts: 84


« Reply #9 on: April 13, 2016, 01:52:32 pm »

thanks Snorri,

that was what I was looking for.
I just copied the pdf-js into the webserver directory and put a pdf in the same Directory.
And with the Sample-URL you send me, the PDF ist displayed in the GDC-Window!

Thanks Stefan
Snorri B.
Posts: 103


« Reply #10 on: April 13, 2016, 01:59:10 pm »

Glad to help!

Regs,
-Snorri
Stefan S.
Posts: 84


« Reply #11 on: April 13, 2016, 02:01:26 pm »

Hello Leo,

The Project I need this for is a completely new Project.
This will be written in Genero 3.0 (even a Windows only enviroment)

But we have a lot of Genero 2.50 Projects and it would be fine to see, if it possible too.

Thanks
Stefan
Leo S.
Four Js
Posts: 119


« Reply #12 on: April 13, 2016, 03:51:02 pm »

I you want to use PDF.js, you definitely need a webserver. You also need to put the file you want to display somewhere in the webservers document directory. For example, when I display a PDF file in GDC through PDF.js the url looks something like:

http://MY_SERVER/pdfview/web/viewer.html?file=../../FILES/filename.pdf

Regards,
-Snorri
Snorri, for a URL based web component this is absolutely correct.
I was referring to a gICAPI based web component.
This requires giving a componentType in the .per and a bit tweaking of the PDFJS  viewer.html (adding the gICAPI boilerplate routines) and then everything is handled locally at the client side without Apache.
I take the  challenge and will come back to this topic if I have something running out of the box.
Regards, Leo
Snorri B.
Posts: 103


« Reply #13 on: April 14, 2016, 04:03:51 pm »

Thank you Leo!

Regards,
-Snorri
Snorri B.
Posts: 103


« Reply #14 on: November 10, 2016, 06:02:19 pm »

I you want to use PDF.js, you definitely need a webserver. You also need to put the file you want to display somewhere in the webservers document directory. For example, when I display a PDF file in GDC through PDF.js the url looks something like:

http://MY_SERVER/pdfview/web/viewer.html?file=../../FILES/filename.pdf

Regards,
-Snorri
Snorri, for a URL based web component this is absolutely correct.
I was referring to a gICAPI based web component.
This requires giving a componentType in the .per and a bit tweaking of the PDFJS  viewer.html (adding the gICAPI boilerplate routines) and then everything is handled locally at the client side without Apache.
I take the  challenge and will come back to this topic if I have something running out of the box.
Regards, Leo


Hi Leo.

Have you managed to look into this? It would be nice to handle everything locally!

Regards,
-Snorri
Pages: [1] 2
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines