Scripting a TeX document - (or other way to number pdf pages)

Caleb Hyde caleb.hyde at gmail.com
Fri Apr 16 02:31:15 UTC 2010


I can think of a scripted solution, that, with some thought and research,
might work.

1. separate the PDF into pages (files)
2. convert PDFs pages to PNG images
3. create PNG files with transparent background and a page number (in some
color), one per each page in the original
4. composite the page-number PNG files (from step 3) onto their respective
page PNG files (from step 2)
5. convert all the files from step 4 back to one PDF file

I researched ImageMagick and found (after about half an hour) that it can
do, at least, steps 4 and 5, on the command line (and step 4 is really the
trickiest step).

ImageMagick provides the command line tool 'convert'. The code for step 4 is
" convert 50.png page-number.png -flatten output.png" and for step 5 is
"convert 50.jpg 51.jpg output.pdf".

So, yeah, I think it can be scripted. I'm willing to work on the rest of the
process with you, if you think this is worth pursuing.

Regards,
Caleb.

ps-- I have some experience with LaTeX and do NOT think it is the right tool
for this job. LaTeX is awesome for formatting documents (physics review
letters, say) into a specific, very polished format. What LaTeX won't do is
parse the PDF source file. You'd have to find some -other- tool to translate
the PDF into a full-fledged LaTeX document (at which point it would be
trivial to add page numbers).



On Mon, Apr 12, 2010 at 5:57 PM, Patton Echols <p.echols at comcast.net> wrote:

> I am working on a modification to the script found here:
>
> http://forums.debian.net/viewtopic.php?t=30598
>
> The purpose is to "page number" an existing PDF document.  Part of the
> process requires a pdf document with the page numbers in the appropriate
> place.  The script author made his manually using OO.  What I would like
> to do is to script the process.  One of the commentators to the script
> said that he made his using LaTeX. (Which I know nothing about).
>
> The documentation I have been able to find is massive and frankly I
> don't  quite know where to begin.
>
> What I would like to do is to feed a script a PDF and have it calculate
> the number of pages "$n", then the script would create the "page number"
> pdf with pages $n, and the correct text, font, color, leading zeros,
> etc.  (Example "Page PE - 00001")
>
>  So here are the questions:
>
> If this is something that can be done with LaTeX? (tex-live)
>
> Nodding in the direction of "RTFM" is there a recommended "FM?" (and
> pointers about what I should be reading!)
>
> Is there another way of doing the above that would be more
> straightforward / scriptable?
>
> Thanks
>
> --PE
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20100415/a909bd0a/attachment.html>


More information about the ubuntu-users mailing list