I know there''s wiki page on generating PDF[*], but that''s not really what I want. I don''t need to create arbitrary PDF. What I''d like to do is create PDF templates and fill in the blanks. Roughly, I''m looking for functionality akin to the mail merge feature of word processors, including conditional and repeated elements, say, table rows. Michael [*] http://wiki.rubyonrails.com/rails/show/HowtoGeneratePDFs -- Michael Schuerig Face reality and stare it down mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org --Jethro Tull, Silver River Turning http://www.schuerig.de/michael/
Michael Schuerig wrote:> I know there''s wiki page on generating PDF[*], but that''s not really > what I want. I don''t need to create arbitrary PDF. What I''d like to do > is create PDF templates and fill in the blanks. Roughly, I''m looking > for functionality akin to the mail merge feature of word processors, > including conditional and repeated elements, say, table rows. > > MichaelThe One True Way (that I''ve come across, anyway) is to generate XML for your document, then use an XSLT template to get XSL:FO which you then translate to a PDF with an external FO engine. Apache FOP is the only open engine I''m aware of - it''s lacking some features, but might be enough for what you''re after. The alternative might be to port PHP FPDI to Ruby FPDF, which would let you embed pdf fragments. Otherwise, investigate pdfTeX :-) -- Alex
Alex Young wrote:>Michael Schuerig wrote: > > >>I know there''s wiki page on generating PDF[*], but that''s not really >>what I want. I don''t need to create arbitrary PDF. What I''d like to do >>is create PDF templates and fill in the blanks. Roughly, I''m looking >>for functionality akin to the mail merge feature of word processors, >>including conditional and repeated elements, say, table rows. >> >>Michael >> >> >The One True Way (that I''ve come across, anyway) is to generate XML for >your document, then use an XSLT template to get XSL:FO which you then >translate to a PDF with an external FO engine. Apache FOP is the only >open engine I''m aware of - it''s lacking some features, but might be >enough for what you''re after. > >The alternative might be to port PHP FPDI to Ruby FPDF, which would let >you embed pdf fragments. > >Otherwise, investigate pdfTeX :-) > > >My favorite is to use html2ps and ps2df back to back to create the documents. You can even combine it with wget for a little extra joy in making PDF''s of offsite content.
On Tue, 2005-09-13 at 18:47 +0200, Michael Schuerig wrote:> I know there''s wiki page on generating PDF[*], but that''s not really > what I want. I don''t need to create arbitrary PDF. What I''d like to do > is create PDF templates and fill in the blanks. Roughly, I''m looking > for functionality akin to the mail merge feature of word processors, > including conditional and repeated elements, say, table rows. > > Michael > > [*] http://wiki.rubyonrails.com/rails/show/HowtoGeneratePDFsI''ve had similar thoughts, but haven''t started coding anything yet, and was gravitating towards using techbook markup for the techbook tool that is part of the ruby pdf::writer module. Seems like it would be a fairly straightforward thing to parse a *.pwd template and insert user input into it. Is this not the sort of solution you need? HTH, Howard
I''ve had a lot of success just calling out to Datavision (java based report writer that uses ruby as it''s scripting language). It''s a bit inefficient firing up a JVM every time you want to generate a PDF, but depending on your use that might work well for you. I''ve written some code to make it easy to call datavision from ruby/ rails and pass along arguments (your blanks that need to be filled in).. On 13-Sep-05, at 1:23 PM, Alex Young wrote:> Michael Schuerig wrote: > >> I know there''s wiki page on generating PDF[*], but that''s not really >> what I want. I don''t need to create arbitrary PDF. What I''d like >> to do >> is create PDF templates and fill in the blanks. Roughly, I''m looking >> for functionality akin to the mail merge feature of word processors, >> including conditional and repeated elements, say, table rows. >> >> Michael >> > The One True Way (that I''ve come across, anyway) is to generate XML > for > your document, then use an XSLT template to get XSL:FO which you then > translate to a PDF with an external FO engine. Apache FOP is the only > open engine I''m aware of - it''s lacking some features, but might be > enough for what you''re after. > > The alternative might be to port PHP FPDI to Ruby FPDF, which would > let > you embed pdf fragments. > > Otherwise, investigate pdfTeX :-) > > -- > Alex > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
I have been doing this for years just by printing something to postscript with the windows postscript driver (it creates human readable postscript I''m not sure how linux drivers compare). The driver uses this A1`65 function to format the text, but you can go in and modify the postscript a little so that your replaced text is spaced normally. -2040 -1827 ( *#address1#*) -2.666595 0 725 5 16 A1`65 ^ ^ ^ ^ ^ x coord y coord text string width maximum letter spacing? convert the above line to this, by adding a moveto after the coordinates, a return carriage, and chaging all the number parameters to "show". -2040 -1827 moveto ( *#address1#*) show Then I run a regexp over the whole thing looking for the *#______#* variables, and insert escaped strings, and it should print fine, or you can send it to ps2pdf. Now what I would really like to know, and perhaps a postscript expert can say how to do this, is how to automatically add return carriages to postscript files. I know it is possible to do this in postscript beceause I''ve seen the hylafax fax coversheet template do this, I looked at the document but it was over my head. Using this you could put paragraphs of text in your templates instead of just little bits and pieces. -Jeff ----- Original Message ----- From: "Michael Schuerig" <michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org> To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Tuesday, September 13, 2005 10:47 AM Subject: [Rails] PDF views?> > I know there''s wiki page on generating PDF[*], but that''s not really > what I want. I don''t need to create arbitrary PDF. What I''d like to do > is create PDF templates and fill in the blanks. Roughly, I''m looking > for functionality akin to the mail merge feature of word processors, > including conditional and repeated elements, say, table rows. > > Michael > > [*] http://wiki.rubyonrails.com/rails/show/HowtoGeneratePDFs > > -- > Michael Schuerig Face reality and stare it down > mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org --Jethro Tull, Silver River Turning > http://www.schuerig.de/michael/ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On Tuesday 13 September 2005 19:43, Lord Khaos wrote:> On Tue, 2005-09-13 at 18:47 +0200, Michael Schuerig wrote: > > I know there''s wiki page on generating PDF[*], but that''s not > > really what I want. I don''t need to create arbitrary PDF. What I''d > > like to do is create PDF templates and fill in the blanks. Roughly, > > I''m looking for functionality akin to the mail merge feature of > > word processors, including conditional and repeated elements, say, > > table rows. > > > > Michael > > > > [*] http://wiki.rubyonrails.com/rails/show/HowtoGeneratePDFs > > I''ve had similar thoughts, but haven''t started coding anything yet, > and was gravitating towards using techbook markup for the techbook > tool that is part of the ruby pdf::writer module. Seems like it would > be a fairly straightforward thing to parse a *.pwd template and > insert user input into it. Is this not the sort of solution you need?No, I don''t think so. I want complete separation of work where a designer prepares a PDF template and a programmer provides the machinery to fill in the blanks. It should be possible to change the templates, while keeping the fields intact, without requiring any changes to the code. Apparently this is not possible with current packages for Ruby, but to me it appears like a very reasonable requirement nonetheless. Michael -- Michael Schuerig Thinking is trying to make up mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org for a gap in one''s education. http://www.schuerig.de/michael/ --Gilbert Ryle
www.PDFlib.com provides a commercial product that might be what you need. You might have to write your own C/Ruby binding for the server side. I chose to write my script using the perl binding, and call the perl from Ruby. Product description excerpt: The "PDFlib Block Plugin for Acrobat" is an interactive tool that enables the designer to define areas (PDFlib blocks) with given properties on top of existing PDF data. PDFlib blocks act as precisely defined containers to be filled with text, images or PDF data in a subsequent server side process. Kyle Maxwell On 9/13/05, Michael Schuerig <michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org> wrote:> On Tuesday 13 September 2005 19:43, Lord Khaos wrote: > > On Tue, 2005-09-13 at 18:47 +0200, Michael Schuerig wrote: > > > I know there''s wiki page on generating PDF[*], but that''s not > > > really what I want. I don''t need to create arbitrary PDF. What I''d > > > like to do is create PDF templates and fill in the blanks. Roughly, > > > I''m looking for functionality akin to the mail merge feature of > > > word processors, including conditional and repeated elements, say, > > > table rows. > > > > > > Michael > > > > > > [*] http://wiki.rubyonrails.com/rails/show/HowtoGeneratePDFs > > > > I''ve had similar thoughts, but haven''t started coding anything yet, > > and was gravitating towards using techbook markup for the techbook > > tool that is part of the ruby pdf::writer module. Seems like it would > > be a fairly straightforward thing to parse a *.pwd template and > > insert user input into it. Is this not the sort of solution you need? > > No, I don''t think so. I want complete separation of work where a > designer prepares a PDF template and a programmer provides the > machinery to fill in the blanks. It should be possible to change the > templates, while keeping the fields intact, without requiring any > changes to the code. Apparently this is not possible with current > packages for Ruby, but to me it appears like a very reasonable > requirement nonetheless. > > Michael > > -- > Michael Schuerig Thinking is trying to make up > mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org for a gap in one''s education. > http://www.schuerig.de/michael/ --Gilbert Ryle > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Tuesday 13 September 2005 22:04, Kyle Maxwell wrote:> www.PDFlib.com provides a commercial product that might be what you > need. You might have to write your own C/Ruby binding for the server > side. I chose to write my script using the perl binding, and call > the perl from Ruby.Yes, it looks good. But it still requires more work than I can afford in my current project. PDF would have been nice, but for the time being I go with HTML/CSS, then. Michael -- Michael Schuerig There is no matrix, mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org only reality. http://www.schuerig.de/michael/ --Lawrence Fishburn
I posted to the list about this a while ago: http://article.gmane.org/ gmane.comp.lang.ruby.rails/16332 Working great for us so far. PDFtk is a bit slow, but our loads for PDF generation are not that high. J On 13 Sep 2005, at 17:47, Michael Schuerig wrote:> > I know there''s wiki page on generating PDF[*], but that''s not really > what I want. I don''t need to create arbitrary PDF. What I''d like to do > is create PDF templates and fill in the blanks. Roughly, I''m looking > for functionality akin to the mail merge feature of word processors, > including conditional and repeated elements, say, table rows. > > Michael > > [*] http://wiki.rubyonrails.com/rails/show/HowtoGeneratePDFs > > -- > Michael Schuerig Face reality and stare it down > mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org --Jethro Tull, Silver River Turning > http://www.schuerig.de/michael/ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
You might want to look at Perl''s PDF::Reuse (http://search.cpan.org/ dist/PDF-Reuse/Reuse.pm) for inspiration. On Sep 13, 2005, at 2:06 PM, Michael Schuerig wrote:> On Tuesday 13 September 2005 22:04, Kyle Maxwell wrote: > >> www.PDFlib.com provides a commercial product that might be what you >> need. You might have to write your own C/Ruby binding for the server >> side. I chose to write my script using the perl binding, and call >> the perl from Ruby. >> > > Yes, it looks good. But it still requires more work than I can > afford in > my current project. PDF would have been nice, but for the time being I > go with HTML/CSS, then. > > Michael > > -- > Michael Schuerig There is no matrix, > mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org only reality. > http://www.schuerig.de/michael/ --Lawrence Fishburn > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Thursday 15 September 2005 15:20, Benjamin Curtis wrote:> You might want to look at Perl''s PDF::Reuse (http://search.cpan.org/ > dist/PDF-Reuse/Reuse.pm) for inspiration.Yes, judging from a quick glance that looks like it is what I want. Wrong language... Michael -- Michael Schuerig Life is just as deadly mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org As it looks http://www.schuerig.de/michael/ --Richard Thompson, Sibella
Michael Schuerig wrote:> On Thursday 15 September 2005 15:20, Benjamin Curtis wrote: > >>You might want to look at Perl''s PDF::Reuse (http://search.cpan.org/ >>dist/PDF-Reuse/Reuse.pm) for inspiration. > > > Yes, judging from a quick glance that looks like it is what I want. > Wrong language...It seems the distance from Perl to Ruby is not so great. What would be the changes to do to convert this to ruby ? -- Jean-Christophe Michel