Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Python

export sites/pages to PDF

 
Jump to:  
 
jvdb
PostPosted: Tue Aug 12, 2008 6:47 pm    Post subject: export sites/pages to PDF
       
Hi all,

My employer is asking for a solution that outputs the content of urls
to pdf. It must be the content as seen within the browser.
Can someone help me on this? It must be able to export several kind of
pages with all kind of content (javascript, etc.)
 

 
Stef Mientki
PostPosted: Tue Aug 12, 2008 6:47 pm    Post subject: Re: export sites/pages to PDF
       
jvdb wrote:
Quote:
Hi all,

My employer is asking for a solution that outputs the content of urls
to pdf. It must be the content as seen within the browser.
Can someone help me on this? It must be able to export several kind of
pages with all kind of content (javascript, etc.)
--
LINK

pdfCreator does the job.


cheers,
Stef
 

 
jvdb
PostPosted: Tue Aug 12, 2008 7:12 pm    Post subject: Re: export sites/pages to PDF
       
Hi Stef!

Thanks for your answer, but i forgot to mention that i have to run
this on unix/linux.


On Aug 12, 9:06 pm, Stef Mientki <stef.mien...@gmail.com> wrote:
Quote:
jvdb wrote:
Hi all,

My employer is asking for a solution that outputs the content of urls
to pdf. It must be the content as seen within the browser.
Can someone help me on this? It must be able to export several kind of
pages with all kind of content (javascript, etc.)
--
LINK

pdfCreator does the job.

cheers,
Stef
 

 
Nick Craig-Wood
PostPosted: Tue Aug 12, 2008 9:33 pm    Post subject: Re: export sites/pages to PDF
       
jvdb <streamservenl@gmail.com> wrote:
Quote:
My employer is asking for a solution that outputs the content of urls
to pdf. It must be the content as seen within the browser.
Can someone help me on this? It must be able to export several kind of
pages with all kind of content (javascript, etc.)

Sounds like you'd be best off scripting a browser.

Eg under KDE you can print to PDF from Konqueror using dcop to remote
control it.

Here is a demo... start Konqueror, select the PDF printer manually
before you start. (You can automate this I expect!)

Run

dcop konq*

to find the id of the running konqueror (in my case
"konqueror-18286"), then open a URL

dcop konqueror-18286 konqueror-mainwindow#1 openURL LINK

To print to a PDF file

dcop konqueror-18286 html-widget2 print 1

Web site converted to PDF in ~/print.pdf ;-)

Easy enough to script that with python.

See here for some more info on dcop :-

LINK

--
Nick Craig-Wood <nick@craig-wood.com> -- LINK
 

 
norseman
PostPosted: Tue Aug 12, 2008 10:11 pm    Post subject: Re: export sites/pages to PDF
       
Nick Craig-Wood wrote:
Quote:
jvdb <streamservenl@gmail.com> wrote:
My employer is asking for a solution that outputs the content of urls
to pdf. It must be the content as seen within the browser.
Can someone help me on this? It must be able to export several kind of
pages with all kind of content (javascript, etc.)

Sounds like you'd be best off scripting a browser.

Eg under KDE you can print to PDF from Konqueror using dcop to remote
control it.

Here is a demo... start Konqueror, select the PDF printer manually
before you start. (You can automate this I expect!)

Run

dcop konq*

to find the id of the running konqueror (in my case
"konqueror-18286"), then open a URL

dcop konqueror-18286 konqueror-mainwindow#1 openURL LINK

To print to a PDF file

dcop konqueror-18286 html-widget2 print 1

Web site converted to PDF in ~/print.pdf ;-)

Easy enough to script that with python.

See here for some more info on dcop :-

LINK


=========================================
If you are running KDE - go with Nick's method.

If the project is as it sounds - an in-house thing.
Meaning the web stuff is created by "you".

IF (BIG IF) you have a limited amount of URLs to deal with
AND
The pages are NOT going to change shape via the print command
(some use one .css for screen and another for print)
AND
you are using UNIX of some sort:

Open the page and print the postscript output to a file.
One file per page.

Then:

with this in a script:
Quote:

#!/bin/sh

# ps2pdf.scr
# converts a single ps file to a pdf file
# april 2000
# SLT
#
ofil=`basename $1 .ps`
gs -sDEVICE=pdfwrite -q \
-dBATCH -dNOPAUSE -r300 \
-sOutputFile=\|cat >$ofil.pdf $1
Quote:


Do:
ps2pdf.scr file.ps


If you have a number of .ps files to convert:

for f in *.ps; do ps2pdf.scr $f; done


In Windows - set the default printer to PDF to file and just print.
Don't expect to concat the PDFs into a single "book",
without a third party program.


NOTE:
If (in UNIX) you want the whole base-on in one file, set up the
printer section to ">>" (append) each output to the single file.
Depending on browser you may need to do some header cleaning.



Steve
norseman@hughes.net
 

 
Tim Roberts
PostPosted: Mon Aug 18, 2008 3:17 am    Post subject: Re: export sites/pages to PDF
       
jvdb <streamservenl@gmail.com> wrote:
Quote:

My employer is asking for a solution that outputs the content of urls
to pdf. It must be the content as seen within the browser.
Can someone help me on this? It must be able to export several kind of
pages with all kind of content (javascript, etc.)

There are a number of obstacles to this. Printer pages are a different
size from screen windows, so the browser does the layout differently.
Further, many style sheets have rules that are "screen only" or "print
only".

If you really want an image of exactly what's on the screen, then I don't
think you have any option other than a screen capture utility, like "xwd".
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

Sklep zoologiczny kitesurfing gratka ubranka dla dzieci konstrukcje profile aluminiowe