| Previous · Next | |
| User | Message |
|
frodwith
|
Date: 7/15/2011 3:22 pm · Subject: WebGUI::Content::PDFGenerator · Rating: 2
If you've ever wanted WebGUI to generate PDFs of your pages for some reason (I've never understood the desire myself, but apparently it's a popular request), have a look at WebGUI::Content::PDFGenerator, which just landed in the master branch and will be in WebGUI 7.10.21 (not enabled by default). It uses WebKit and QT to render html pages to pdfs -- just add ?op=generatePdf to your page url. Feedback/patches welcome! |
| Back to Top |
Rate [ | ]
|
|
martien
|
Date: 8/17/2011 5:14 pm · Subject: Re: WebGUI::Content::PDFGenerator · Rating: -1
A great idea to use wkhtmltopdf. I also started using it to generate complete Websitedocs and/or documenting a bunch of URLs. Your package could easily be changed/expanded to use wkhtmltoimage to generate snapshots too. |
| Back to Top |
Rate [ | ]
|
|
martien
|
Date: 8/31/2011 7:48 am · Subject: Re: WebGUI::Content::PDFGenerator · Rating: -1
How would you/ can you get a pdf of a page within the Account Module? There's something like "?op=account;module=shop;do=viewTransaction;transactionId=AiVN95AJ-uDLIUP_9pL63w" problems:
|
| Back to Top |
Rate [ | ]
|
|
scottwalters
|
Date: 9/20/2011 4:42 pm · Subject: Re: WebGUI::Content::PDFGenerator · Rating: -1
Re: being logged in, if you're fetching the page with some robot (such as perhaps wget), WebGUI supports using HTTP Basic auth. wget 'http://user|pass@webgui.site.com/protected/content' should work. JavaScript on the page shouldn't be a problem as WebKit will simply run it and dynamic content is given a moment to settle before the pdf is generated. Trying to mix and match two account plugins (op=) is a problem, though. I don't have any suggestions there other than modifying the code to accept more parameters and kick-off dispatch again in various other ways than it does. |
| Back to Top |
Rate [ | ]
|
|
vanjwilson
|
Date: 9/14/2011 1:17 pm · Subject: Re: WebGUI::Content::PDFGenerator · Rating: -1
Getting this error in webgui.log when I try to generate a PDF of a page: Can't use string ("--orientation Landscape") as an ARRAY ref while "strict refs" in use at /data/WebGUI/lib/WebGUI/Content/PDFGenerator.pm line 97 I'm using the default settings from the docs for PDFGenerator, but with "wkhtmltopdf" in the same directory as wre's perl: "pdfGen" :{ |
| Back to Top |
Rate [ | ]
|
|
martien
|
Date: 9/14/2011 3:58 pm · Subject: Re: WebGUI::Content::PDFGenerator · Rating: 0
In the program it reads: my @args = (
"args" : [ "--orientation", "Landscape" ], |
| Back to Top |
Rate [ | ]
|
|
vanjwilson
|
Date: 9/16/2011 2:42 pm · Subject: Re: WebGUI::Content::PDFGenerator · Rating: -1
@martien: Your suggestion of putting brackets around the args in the WebGUI .conf file to make them an array worked (e.g., "args" : [ "--orientation", "Landscape" ],). Now that I can successfully create PDFs, I've run into a couple more issue: 1) I need to make PDFs of report pages, but when I add the "op=generatPdf" to my query string with the various search parameters, none of the other params get passed in the URL to wkhtmltopdf. The SQL report that comes back is not filtered at all. We are also using a custom macro to keep track of locations that our client wants query from page to page, and the custom macro is not running in the layout either. 2) For multi-page SQL reports, the PDF is only capturing the first page and the link list at the bottom. I think I may need to create a PDF-only copy of this page, with an SQL report that is not paginated, just to pass to GeneratePDF. Does that sound right? 3) Finally, the production server for this site is running on Mac OSX. I have installed wkhtmltopdf and gotten it to run by itself, but when I try to use the GeneratePDF content handler, I get this error in the modperl.error.log: Fri Sep 16 14:36:42 minimac.*****.com wkhtmltopdf[47214] <Error>: kCGErrorRangeCheck: On-demand launch of the Window Server is allowed for root user only. Has anyone gotten this to work on a Mac server? |
| Back to Top |
Rate [ | ]
|
|
martien
|
Date: 9/16/2011 4:49 pm · Subject: Re: WebGUI::Content::PDFGenerator · Rating: -1
that's right, since you get the arguments only from the config.
yes
Which version of wktohtml are you using? #!/bin/bash Ofacourse you also can start Xvfb at boottime Because all of the restrictions, I developed a new application, where it's possible to get more than one URL Is that where you're looking for? (s. http://www.webgui-professional.de/websitedoc/website2pdfbookAs an example, you'll find there temporarely a pdf with a 140 page WebGUI Webshop doc. Hope, this helps |
| Back to Top |
Rate [ | ]
|
|
vanjwilson
|
Date: 9/20/2011 3:06 pm · Subject: Re: WebGUI::Content::PDFGenerator · Rating: -1
@martien, Thanks for the help. I upgraded wkhtmltopdf to "0.10.0 rc2 static" for OSX, and now it works on our Mac server, too. (The docs for wkhtmltopdf give the details.) The big issue now is the content handler not passing the query string from the URL, so that a filtered report page is returned. I don't know WebGUI internals very well, but this code in PDFGenerator's "generate" sub seems like what I would need to modify to get params passed: my @args = ( (I might need to filter out the "op=generatePdf" in the query string.) This seems similar to the issue you were having with the two "op" codes above. |
| Back to Top |
Rate [ | ]
|
|
scottwalters
|
Date: 9/20/2011 7:51 pm · Subject: Re: WebGUI::Content::PDFGenerator · Rating: -1
Yeah, I came to the same conclustion, that bit of code would need to be modified. I took a stab at it but, beyond syntax tests, haven't tested it at all. I may have time to test/debug later. I've posted what I have here: https://github.com/scrottie/webgui/blob/75de562325af2ded1f0297b654ab39dd2ca0d4e0/lib/WebGUI/Content/PDFGenerator.pm That tries to send over all of the form paramters that it can, excluding the op parameter, of course. You should be able to replace your copy of the file with this one. If it works, I'd like to know about it so I can see about adding that change to core. Thanks, -scott |
| Back to Top |
Rate [ | ]
|