Title: Display PDF-Files in GDC Post by: Stefan S. 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 Title: Re: Display PDF-Files in GDC Post by: Lionel F. 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 Title: Re: Display PDF-Files in GDC Post by: Reuben B. 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 Title: Re: Display PDF-Files in GDC Post by: Stefan S. 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 Title: Re: Display PDF-Files in GDC Post by: Snorri B. 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 Title: Re: Display PDF-Files in GDC Post by: Stefan S. 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 Title: Re: Display PDF-Files in GDC Post by: Snorri B. 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 Title: Re: Display PDF-Files in GDC Post by: Leo S. 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 Title: Re: Display PDF-Files in GDC Post by: Snorri B. 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 Title: Re: Display PDF-Files in GDC Post by: Stefan S. 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 Title: Re: Display PDF-Files in GDC Post by: Snorri B. on April 13, 2016, 01:59:10 pm Glad to help!
Regs, -Snorri Title: Re: Display PDF-Files in GDC Post by: Stefan S. 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 Title: Re: Display PDF-Files in GDC Post by: Leo S. 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: Snorri, for a URL based web component this is absolutely correct.http://MY_SERVER/pdfview/web/viewer.html?file=../../FILES/filename.pdf Regards, -Snorri 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 Title: Re: Display PDF-Files in GDC Post by: Snorri B. on April 14, 2016, 04:03:51 pm Thank you Leo!
Regards, -Snorri Title: Re: Display PDF-Files in GDC Post by: Snorri B. 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: Snorri, for a URL based web component this is absolutely correct.http://MY_SERVER/pdfview/web/viewer.html?file=../../FILES/filename.pdf Regards, -Snorri 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 Title: Re: Display PDF-Files in GDC Post by: Leo S. on November 14, 2016, 12:56:57 am Hi Snorri, I got it to work , but...
I would not actually recommend to use it. Why? We did prepare webcomponents in 3.00 to use build in transmission for the web components html/javascript/css assets to the client. Unfortunately this transmission does not work for this particular component (its a bug, but a bug being deeply in QtWebKit, so we are unable to fix this easily), the visual effect is that the html page is shown as source code instead of being rendered... I hope that we can fix that for vNext . What does work is uploading all needed pieces via fgl_putfile() to the clients data dir and using the setwebcomponentpath frontcall...this implies however that all webcomponents using this particular program need to be uploaded. You need to check also the assets needed for uploading: the sample works for US locale but for other locales you might need to upload additional assets. I attach the solution here, as said, its not really nice and understandable due to the uploading hassles. Note that the makefile is pretty OSX centric : it uses curl to download the pdfjs stuff, but it should be easily adaptable to Linux. The core of the trick: a small patch implants a gICAPI.js in the main page and enables you to call the displayPDF JS function via a webco frontcall. % make main.run press the "show" button and it should show a little demo with a pdf file. Title: Re: Display PDF-Files in GDC Post by: Leo S. on November 14, 2016, 01:33:45 am Small addition: the problem appears only if GDC is connected directly or via SSH with the server.
Going via GAS and loading the webcomponent via http does work flawlessly (btw it does work also for GWC-JS) I updated the main.4gl and attach here (you see the different ways are distinguished with the viaGAS variable) Leo Title: Re: Display PDF-Files in GDC Post by: Snorri B. on November 14, 2016, 12:21:44 pm Thanks Leo.
I will look into this. Probably it's just easier to have it all server side. Too many things could go wrong on > 300 clients. Regards, -Snorri Title: Re: Display PDF-Files in GDC Post by: Leo S. on November 14, 2016, 12:58:31 pm Hi Snorri , I'd like to add that it would work anyway only for GDC3.00 , not 2.50 .
Regards, Leo Title: Re: Display PDF-Files in GDC Post by: Snorri B. on November 14, 2016, 03:50:39 pm Hi Snorri , I'd like to add that it would work anyway only for GDC3.00 , not 2.50 . Regards, Leo Yes, I'm aware of that. Thanks, -Snorri |