You are not logged in.

#1 2010-02-14 09:31:32

whacath
Member
Registered: 2009-05-26
Posts: 283

xkcd+alt-text in a pdf?

I would love to see some kind of tool, a script that download every xkcd comic and the alt text and put them in a pdf file. It would be great to print and put on the can for everyone to read. smile

Anybody of you guys that knows of a script that does this? Or are willing to create one? smile

Offline

#2 2010-02-14 09:41:33

Vamp898
Member
From: ドイツではまだ住んでいる
Registered: 2009-01-03
Posts: 866
Website

Re: xkcd+alt-text in a pdf?

I think the download is quiet easy but how to put them into PDF hmm Doesn´t the print tool support PDF?

Offline

#3 2010-02-14 15:34:29

Garns
Member
Registered: 2008-05-28
Posts: 239

Re: xkcd+alt-text in a pdf?

I hacked up some latex to create the pdf but I still have to write some script for downloading. Results will look approximately like this.

If you want to check out the tex file (which is pretty crappy by the way, I am sure this could be done a lot better) look here.

Offline

#4 2010-02-14 16:42:36

Atragor
Member
Registered: 2009-02-28
Posts: 59

Re: xkcd+alt-text in a pdf?

OMG, I've completely forgot about Latex. Anyway, here is my quick and dirty code, it uses community/python-reportlab and extra/python-imaging. Resulting PDF file with the first 3 comics is here

P.S. I haven't found how to specify a font in reportlab apart from using an absolute path, so replace '/tmp/tahoma.ttf' in the source with the path to your favorite font.

Last edited by Atragor (2010-02-14 16:51:05)

Offline

#5 2010-02-17 00:08:30

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: xkcd+alt-text in a pdf?

Atragor wrote:

OMG, I've completely forgot about Latex. Anyway, here is my quick and dirty code, it uses community/python-reportlab and extra/python-imaging. Resulting PDF file with the first 3 comics is here

P.S. I haven't found how to specify a font in reportlab apart from using an absolute path, so replace '/tmp/tahoma.ttf' in the source with the path to your favorite font.

Thanks mate! That works perfectly!
I'm downing them all now big_smile

I wonder if this is possible with Cyanide and Happiness too...

Last edited by sand_man (2010-02-18 00:35:20)


neutral

Offline

#6 2010-02-20 13:26:06

Atragor
Member
Registered: 2009-02-28
Posts: 59

Re: xkcd+alt-text in a pdf?

I've modified my script to add support for Latex and Cyanide & Happiness.
Notes:
1) now '-s', '-g' and '-d' command-line options can be used to specify a site, a PDF generation method and a cache directory accordingly
2) the cache directory now has two subdirectories (xkcd_cache, cyanide_cache)
3) YouTube movies on Cyanide & Happiness are not supported, also GIF images are skipped in Latex mode because Latex doesn't support GIF

link

Offline

#7 2010-02-22 22:21:54

whacath
Member
Registered: 2009-05-26
Posts: 283

Re: xkcd+alt-text in a pdf?

Really cool script! big_smilecool

Dependencies needed to run the script: python-imaging and python-reportlab

It would be nice if the script put more then one strip per page, maybe two or three and the alt-text below every comic instead of above. smile

Offline

#8 2010-02-22 22:33:55

whacath
Member
Registered: 2009-05-26
Posts: 283

Re: xkcd+alt-text in a pdf?

oh, i forgot, http://www.amazingsuperpowers.com should be added too! big_smile

Offline

#9 2010-02-22 23:04:32

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: xkcd+alt-text in a pdf?

Thanks Atragor, works perfectly!

Edit:
One small problem is that it doesn't seem to like file names with spaces in it. At least with cyanide.

Adding #359
    Downloading http://www.explosm.net/db/files/Comics/jump rope0001.jpg
Traceback etc etc
*
*
*

Sorry I had to type it manually because copy+paste isn't working from my VM for some reason.

Last edited by sand_man (2010-02-23 01:16:41)


neutral

Offline

#10 2010-02-23 23:11:29

Atragor
Member
Registered: 2009-02-28
Posts: 59

Re: xkcd+alt-text in a pdf?

New version is here.
1) Fixed problem with spaces
2) Now as much images as possible are placed on one page when using reportlab
3) Added --scale option to allow zooming of images
4) Added support for amazingsuperpowers.com. Example:

./comics_pdf.py -s asp asp.pdf '11-2009' '01-2010'

This command will download all comics having date from November 2009 to January 2010 inclusive.

link

Last edited by Atragor (2010-02-24 22:22:10)

Offline

#11 2010-02-25 00:53:12

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: xkcd+alt-text in a pdf?

Atragor wrote:

2) Now as much images as possible are placed on one page when using reportlab

Thanks, I was gonna ask about that too.

Last edited by sand_man (2010-02-25 01:07:28)


neutral

Offline

#12 2010-02-25 13:00:38

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: xkcd+alt-text in a pdf?

Wouldn't it better if the alt-text was below the image, not above it?


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#13 2010-02-28 11:29:11

whacath
Member
Registered: 2009-05-26
Posts: 283

Re: xkcd+alt-text in a pdf?

Atragor wrote:

New version is here.
1) Fixed problem with spaces
2) Now as much images as possible are placed on one page when using reportlab
3) Added --scale option to allow zooming of images
4) Added support for amazingsuperpowers.com. Example:

./comics_pdf.py -s asp asp.pdf '11-2009' '01-2010'

This command will download all comics having date from November 2009 to January 2010 inclusive.

link

Great! You are our god! smile

But "putting more then one comic on one page" doesnt  seem to work with xkcd comics hmm

I just had an idea. maybe it would be easier to instead of pdf, use html. To put the comics in a html-file instead. I think this would solve the "putting more then one comic on one page"-issue and then if one would want a pdf one could just use firefox "print to pdf"-option.

What do you guys think?

Offline

#14 2010-02-28 22:42:04

whacath
Member
Registered: 2009-05-26
Posts: 283

Re: xkcd+alt-text in a pdf?

...Or as Picard would say it: "Make it so!" wink

Offline

#15 2010-03-02 18:30:48

Atragor
Member
Registered: 2009-02-28
Posts: 59

Re: xkcd+alt-text in a pdf?

whacath wrote:

But "putting more then one comic on one page" doesnt  seem to work with xkcd comics hmm

It works, but since most images are too large, reportlab places only one image per page. Use --scale option to decrease sizes of images.

moljac024 wrote:

Wouldn't it better if the alt-text was below the image, not above it?

Done.


Updated the script.
1) Added --margin-{left,right,top,bottom} options to specify margins (in inches) when using reportlab
2) Added an ability to output comics to a HTML-file
3) Added --title-font-size and --alt-font-size options (guess what they do smile)
4) --scale option renamed into --image-scale

Output to HTML currently doesn't support image scaling to remove the dependence on python-imaging when using this mode.

link

Last edited by Atragor (2010-03-02 18:34:47)

Offline

#16 2010-03-03 03:54:45

matthewbauer
Member
From: /usa/ks
Registered: 2009-07-20
Posts: 86

Re: xkcd+alt-text in a pdf?

Try this:

number=100; for a in $(seq 1 $number); do curl -sL xkcd.com/$a | grep '<img [^>]*/><br/>' | sed -r 's|<img src="(.*)" title="(.*)" alt="(.*)" /><br/>|\1\t\2\t\3|' > /tmp/a; curl -s $(cat /tmp/a | cut -f1) | convert - -gravity south -draw "text 0,0 \"$(cat /tmp/a | cut -f2)\"" pdf:- > /tmp/$a.pdf; done; gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=xkcd.pdf $(seq 1 $number | sed -r 's/(.*)/\/tmp\/\1.pdf/'); rm /tmp/a /tmp/*.pdf

Last edited by matthewbauer (2010-03-04 01:45:19)


Libertarian Arch Linux User

Offline

#17 2010-03-03 11:30:16

whacath
Member
Registered: 2009-05-26
Posts: 283

Re: xkcd+alt-text in a pdf?

@Atragor really nice! smile we ask, you deliver!

@matthewbauer that creates pdf-files for every strip, not very usable. tongue

Offline

#18 2010-03-03 12:37:41

jstadler
Member
From: Canada
Registered: 2010-01-04
Posts: 47

Re: xkcd+alt-text in a pdf?

yea thats pretty cool what you did there

Offline

#19 2010-03-04 00:18:32

whacath
Member
Registered: 2009-05-26
Posts: 283

Re: xkcd+alt-text in a pdf?

Now more feature requests by me! yikes

The progam need a name and to be put into the aur.

a name suggestion: "comichämter" - a mix between english and swedish languages wich means somethinh like "comicget"  smile

And now a impossible feature request:

It would be really really nice to have some kind of program that monitor xkcd.com and download the comic, converts it to pdf and print it, all automatically at every new release. smile

Offline

Board footer

Powered by FluxBB