Prag Programmers style PDF personalization

1 view
Skip to first unread message

jworth...@gmail.com

unread,
Aug 19, 2006, 3:02:08 AM8/19/06
to Ruby on Rails: Talk
Any ideas on implementing PDF personalization ala the Pragmatic
Programmer e-books with Rails? The source books are already PDFs. I did
some experiments using PDFtk, but it seemed a little indirect/

jw

carmen

unread,
Aug 19, 2006, 4:31:52 AM8/19/06
to rubyonra...@googlegroups.com

someone documented their experience dealing w/ pdf nonsense:
http://ansuz.sooke.bc.ca/software/pdf-append.php

Manuel Holtgrewe

unread,
Aug 19, 2006, 8:15:32 AM8/19/06
to rubyonra...@googlegroups.com

I could imagine that they are rebuiling the whole book from LaTeX
sources on every request.

*m

--
I have found an elegant and short solution for Fermat's Theorem
but sadly there is not enough space for it in this signature.


iolaire

unread,
Aug 19, 2006, 9:05:41 AM8/19/06
to Ruby on Rails: Talk
One example is shown over at:
http://wiki.rubyonrails.org/rails/pages/HowtoGeneratePDFs
In the section
PDF Form Fill

Craig

unread,
Aug 19, 2006, 9:30:48 AM8/19/06
to rubyonra...@googlegroups.com
I do something similar, but I haven't found an easy way to do it using
Ruby. I use a PHP script:
http://fpdi.setasign.de/

Works like a charm and quite quick.


--
Posted via http://www.ruby-forum.com/.

Julian 'Julik' Tarkhanov

unread,
Aug 19, 2006, 9:44:21 AM8/19/06
to rubyonra...@googlegroups.com
I settled on a Perl solution with PDF::Reuse

http://www.bigbold.com/snippets/posts/show/1704

but it seems o be impossible to do UTF-8 with it :-(

On 19-aug-2006, at 15:30, Craig wrote:

> I do something similar, but I haven't found an easy way to do it using
> Ruby. I use a PHP script:
> http://fpdi.setasign.de/
>
> Works like a charm and quite quick.

--
Julian 'Julik' Tarkhanov
please send all personal mail to
me at julik.nl


Austin Ziegler

unread,
Aug 19, 2006, 9:48:05 AM8/19/06
to rubyonra...@googlegroups.com
On 8/19/06, Julian 'Julik' Tarkhanov <lis...@julik.nl> wrote:
> I settled on a Perl solution with PDF::Reuse
>
> http://www.bigbold.com/snippets/posts/show/1704
>
> but it seems o be impossible to do UTF-8 with it :-(

That's because you're asking for something impossible from PDF. You
can check the spec if you're interested.

-austin
--
Austin Ziegler * halos...@gmail.com * http://www.halostatue.ca/
* aus...@halostatue.ca * http://www.halostatue.ca/feed/
* aus...@zieglers.ca

Julian 'Julik' Tarkhanov

unread,
Aug 19, 2006, 10:07:03 AM8/19/06
to rubyonra...@googlegroups.com

On 19-aug-2006, at 15:48, Austin Ziegler wrote:

> That's because you're asking for something impossible from PDF. You
> can check the spec if you're interested.

Would you please elaborate? My idea was not to port PDF::Reuse to
Ruby, I am using it as is (especially considering that it's heavily
commented in Swedish and I barely understand a word).

I have been producing PDF documents with Russian text for about 5
years now (with other means), as well as copied text from them
afterwards.

Pau Garcia i Quiles

unread,
Aug 19, 2006, 10:43:14 AM8/19/06
to rubyonra...@googlegroups.com

You could rebuild the whole PDF from LaTeX everytime, as Manuel Holtgrewe
suggested, but I think using Postscript would make the process easier and
less resource-hungry:

1. Generate a master PostScript file from the LaTeX, with placeholder text in
the customizable field (for instance: "Prepared exclusively for <name>")
2. Run sed to replace "<name>" with the new text, then pipe that to ps2pdf

--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to the amount of work, I usually need 10 days to answer)

Austin Ziegler

unread,
Aug 19, 2006, 11:47:39 AM8/19/06
to rubyonra...@googlegroups.com
On 8/19/06, Julian 'Julik' Tarkhanov <lis...@julik.nl> wrote:
> On 19-aug-2006, at 15:48, Austin Ziegler wrote:
>> That's because you're asking for something impossible from PDF. You
>> can check the spec if you're interested.
> Would you please elaborate? My idea was not to port PDF::Reuse to
> Ruby, I am using it as is (especially considering that it's heavily
> commented in Swedish and I barely understand a word).

PDF -- the spec -- does not support UTF-8. Therefore, you cannot use
UTF-8 with PDF.

> I have been producing PDF documents with Russian text for about 5
> years now (with other means), as well as copied text from them
> afterwards.

Right. That's because *either* the PDF was generated with a Russian
font and encoding (for 8-bit values) *or* the PDF was generated with a
Unicode font and UTF-16BE encoding.

Dave Thomas

unread,
Aug 19, 2006, 1:12:16 PM8/19/06
to rubyonra...@googlegroups.com

On Aug 19, 2006, at 9:43 AM, Pau Garcia i Quiles wrote:

> 1. Generate a master PostScript file from the LaTeX, with
> placeholder text in
> the customizable field (for instance: "Prepared exclusively for
> <name>")
> 2. Run sed to replace "<name>" with the new text, then pipe that to
> ps2pdf


That's how we used to do it, but when we have a lot of requests for
PDFs (which we do when we announce a new version of the Rails Beta,
for example) it was too slow.

We now use a commercial product designed to do just this--stamp stuff
onto PDF pages.


Cheers


Dave


Pau Garcia i Quiles

unread,
Aug 19, 2006, 1:50:29 PM8/19/06
to rubyonra...@googlegroups.com
On Saturday 19 August 2006 19:12, Dave Thomas wrote:

> That's how we used to do it, but when we have a lot of requests for
> PDFs (which we do when we announce a new version of the Rails Beta,
> for example) it was too slow.

Talking about AWDWR2-beta, is there any date for the new iteration?

Jeremy McAnally

unread,
Aug 19, 2006, 4:43:27 PM8/19/06
to rubyonra...@googlegroups.com
Care to share what product that is, Dave? I've tried a few and they
all suck royally when put under any load. Most of the ones I've found
are meant for personal use, or for someone to be right there doing it
manually.

--Jeremy

Dave Thomas

unread,
Aug 19, 2006, 7:23:19 PM8/19/06
to rubyonra...@googlegroups.com

On Aug 19, 2006, at 12:50 PM, Pau Garcia i Quiles wrote:

> Talking about AWDWR2-beta, is there any date for the new iteration?


When it's done... :)

I'm just about finished ActionPack, but the change to Reloadable
means I have to rework the Depot code from the cart onwards, and
rewrite those three pages in the cart creation chapter... :(

Dave Thomas

unread,
Aug 19, 2006, 7:27:38 PM8/19/06
to rubyonra...@googlegroups.com

On Aug 19, 2006, at 3:43 PM, Jeremy McAnally wrote:

> Care to share what product that is, Dave? I've tried a few and they
> all suck royally when put under any load. Most of the ones I've found
> are meant for personal use, or for someone to be right there doing it
> manually.


It's pdstamp.

Product works fine for us. Company it comes from is not the easiest
to deal with.


Dave

Julian 'Julik' Tarkhanov

unread,
Aug 19, 2006, 7:39:58 PM8/19/06
to rubyonra...@googlegroups.com

On 19-aug-2006, at 17:47, Austin Ziegler wrote:

>> Would you please elaborate? My idea was not to port PDF::Reuse to
>> Ruby, I am using it as is (especially considering that it's heavily
>> commented in Swedish and I barely understand a word).
>
> PDF -- the spec -- does not support UTF-8. Therefore, you cannot use
> UTF-8 with PDF.

It doesn't matter for me that much as long as it's Unicode, be it
UTF16BE, LE or 32 or 8. The fact is that I can't for the life of me
figure out how to pipe unicode text to be stamped in the "default"
fonts. Just a thought of using special (especially Unicode) fonts on
OSS platforms together with that tool sends shivers down my spine.

You will refer me to the complete obscure PDF spec once again so I
will shut up now. I wonder how your solution handles Unicode text,
but I admit I'm too lazy to try it out (and the question of PDF re-
use as opposed to PDf creation is more important for me right now).

Austin Ziegler

unread,
Aug 19, 2006, 8:22:34 PM8/19/06
to rubyonra...@googlegroups.com
On 8/19/06, Julian 'Julik' Tarkhanov <lis...@julik.nl> wrote:
> It doesn't matter for me that much as long as it's Unicode, be it
> UTF16BE, LE or 32 or 8. The fact is that I can't for the life of me
> figure out how to pipe unicode text to be stamped in the "default"
> fonts. Just a thought of using special (especially Unicode) fonts on
> OSS platforms together with that tool sends shivers down my spine.

Um. I'm not sure that the default fonts are Unicode capable.

> You will refer me to the complete obscure PDF spec once again so I
> will shut up now. I wonder how your solution handles Unicode text,
> but I admit I'm too lazy to try it out (and the question of PDF re-
> use as opposed to PDf creation is more important for me right now).

PDF::Writer doesn't solve the Unicode problem yet.

Julian 'Julik' Tarkhanov

unread,
Aug 21, 2006, 1:16:03 PM8/21/06
to rubyonra...@googlegroups.com

On 20-aug-2006, at 2:22, Austin Ziegler wrote:

> PDF::Writer doesn't solve the Unicode problem yet.

Which brings our Unicode discussion that once happened into new
light :-)
thanks for the statement

Austin Ziegler

unread,
Aug 22, 2006, 4:26:41 PM8/22/06
to rubyonra...@googlegroups.com
On 8/21/06, Julian 'Julik' Tarkhanov <lis...@julik.nl> wrote:
> On 20-aug-2006, at 2:22, Austin Ziegler wrote:
>> PDF::Writer doesn't solve the Unicode problem yet.
> Which brings our Unicode discussion that once happened into new
> light :-)
> thanks for the statement

Not really. The Unicode problem for PDF support is wholly unrelated to
my stance on Unicode vs. m17n Strings. The Unicode problem for PDF
support is mostly that the PDF standards doc is a stinking pile that
is almost impossible to understand without your eyes bleeding and even
harder to implement. ;)

Most strings are written one way for normal 8-bit strings in PDF;
they're written an entirely different way when using UTF-16BE. I just
haven't got the output format working yet. The *only* thing that would
help me with the m17n String and PDF is that I could forcibly convert
between encoding-x and UTF-16 for output -- but a Unicode string would
leave me less able to deal with this sort of stuff nicely.

Julian 'Julik' Tarkhanov

unread,
Aug 26, 2006, 11:57:21 AM8/26/06
to rubyonra...@googlegroups.com

On 22-aug-2006, at 22:26, Austin Ziegler wrote:

> Not really. The Unicode problem for PDF support is wholly unrelated to
> my stance on Unicode vs. m17n Strings. The Unicode problem for PDF
> support is mostly that the PDF standards doc is a stinking pile that
> is almost impossible to understand without your eyes bleeding and even
> harder to implement. ;)

I just couldn't miss a chance to shake the stick in the notion of "I
did implement Unicode in my app, why didn't you?"
But the way it seems to work in PDF is indeed inexplicably terrible,
so this should wait. Although that makes PDF::Writer unusable for my
for just about any purpose (except formatting subversion changelogs
and other ppurely programming-related documentation that is
guaranteed to be ASCII). hope you pardon my pun.

I will try to contact the pdstamp people and ask them how they handle
the problem, I might need a Unicode-aware stamper soon.

Reply all
Reply to author
Forward
0 new messages