In a new app we are developing, we need to be able to dynamically create a PDF and send it to the browser (inline with send_data). I have been tinkering with PDF::Writer and love the simplicity and native ruby-ness of it all. However, one of the main uses for this functionality is to output a PDF of addresses to be printed on Avery 5161 labels. LaTex seems to be suited well for this, but it sure feels like the long way home getting it all hooked up together. My question is this: Is there a way to do this in PDF::Writer that I am missing? If not, what is the best way to hook up LaTex to my rails app? -- Posted via http://www.ruby-forum.com/.
On 15/12/05, Brad Daily <brad-gF2YUKaa3i2Mzk71e9gJXA@public.gmane.org> wrote:> In a new app we are developing, we need to be able to dynamically create > a PDF and send it to the browser (inline with send_data). I have been > tinkering with PDF::Writer and love the simplicity and native ruby-ness > of it all. > > However, one of the main uses for this functionality is to output a PDF > of addresses to be printed on Avery 5161 labels. LaTex seems to be > suited well for this, but it sure feels like the long way home getting > it all hooked up together. > > My question is this: Is there a way to do this in PDF::Writer that I am > missing? If not, what is the best way to hook up LaTex to my rails app?Yes, there''s a way. No, it''s not "automatic" right now. If you''re interested in taking the steps necessary to make PDF::Writer do the right thing for labels, I''ll happily incorporate it into PDF::Writer. Otherwise, it will have to wait until I have time to do it. There are some examples in the open source world already (in other languages) on how to best do this, and as long as it''s under the PDF::Writer licence (essentially MIT-licensed, friendly to both open source and commercial interests), I''ll incorporate it. -austin -- Austin Ziegler * halostatue-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org * Alternate: austin-/yODNl0JVVCozMbzO90S/Q@public.gmane.org
Thanks Austin - After a few hours of piddling this afternoon, I have PDF Writer outputting my data into the right position for the labels we are using. I hope to share the process once it is refined a little, nothing to earth shattering, mostly using a ruler to plot out the key points :) I am wondering if anyone has successfully worked around the UTF limitation. We have accented characters that are my last hurdle to get this thing working... Thanks again for a great lib! Austin Ziegler wrote:> On 15/12/05, Brad Daily <brad-gF2YUKaa3i2Mzk71e9gJXA@public.gmane.org> wrote: >> My question is this: Is there a way to do this in PDF::Writer that I am >> missing? If not, what is the best way to hook up LaTex to my rails app? > > Yes, there''s a way. No, it''s not "automatic" right now. If you''re > interested in taking the steps necessary to make PDF::Writer do the > right thing for labels, I''ll happily incorporate it into PDF::Writer. > Otherwise, it will have to wait until I have time to do it. There are > some examples in the open source world already (in other languages) on > how to best do this, and as long as it''s under the PDF::Writer licence > (essentially MIT-licensed, friendly to both open source and commercial > interests), I''ll incorporate it. > > -austin > -- > Austin Ziegler * halostatue-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > * Alternate: austin-/yODNl0JVVCozMbzO90S/Q@public.gmane.org-- Posted via http://www.ruby-forum.com/.
Austin, I would also me interesting in such an implementation with the possibility of using bar-code drawn on the labels... Do you see any problems with having bar codes fonts? regards, Leon On 12/16/05, Brad Daily <brad-gF2YUKaa3i2Mzk71e9gJXA@public.gmane.org> wrote:> > Thanks Austin - After a few hours of piddling this afternoon, I have PDF > Writer outputting my data into the right position for the labels we are > using. I hope to share the process once it is refined a little, nothing > to earth shattering, mostly using a ruler to plot out the key points :) > > I am wondering if anyone has successfully worked around the UTF > limitation. We have accented characters that are my last hurdle to get > this thing working... > > Thanks again for a great lib! > > Austin Ziegler wrote: > > On 15/12/05, Brad Daily <brad-gF2YUKaa3i2Mzk71e9gJXA@public.gmane.org> wrote: > >> My question is this: Is there a way to do this in PDF::Writer that I am > >> missing? If not, what is the best way to hook up LaTex to my rails app? > > > > Yes, there''s a way. No, it''s not "automatic" right now. If you''re > > interested in taking the steps necessary to make PDF::Writer do the > > right thing for labels, I''ll happily incorporate it into PDF::Writer. > > Otherwise, it will have to wait until I have time to do it. There are > > some examples in the open source world already (in other languages) on > > how to best do this, and as long as it''s under the PDF::Writer licence > > (essentially MIT-licensed, friendly to both open source and commercial > > interests), I''ll incorporate it. > > > > -austin > > -- > > Austin Ziegler * halostatue-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > * Alternate: austin-/yODNl0JVVCozMbzO90S/Q@public.gmane.org > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- First they laugh at you, then they ignore you, then they fight you. Then you win. -- Mahatma Karamchand Gandhi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hi Austin, Brad, Has any progress / work been done on bringing easy label support to PDF Writer? I can see that it was talked about here, and that labels can be made with PDF Writer as is, but before I dive in and start coding something I was wondering if anyone already was. Right now I have an app that makes calles to glabel-batch (command line gLabels) at its back end to print labels. The user can specify a template created with gLabels (http://glabels.sourceforge.net/) and then each time a record is added or updated a new label for it can be printed. I''d like to remove my dependancy on gLabels (and more importantly the dependancy on Gnome), since this is not really cross platform. If no one else is on this I will probably setup a parser for the gLabels XML format, that can be used in conjuntion with PDF Writer. There is a lot of work that''s gone into the XML template library in gLabels, and since sitting down with a ruler doesn''t appeal to me, I think that bootstrapping a Ruby labelling solution to that make a lot of since. Thoughts? Rob Kaufman On 12/15/05, Brad Daily <brad@bradleyboy.com> wrote:> Thanks Austin - After a few hours of piddling this afternoon, I have PDF > Writer outputting my data into the right position for the labels we are > using. I hope to share the process once it is refined a little, nothing > to earth shattering, mostly using a ruler to plot out the key points :) > > I am wondering if anyone has successfully worked around the UTF > limitation. We have accented characters that are my last hurdle to get > this thing working... > > Thanks again for a great lib! > > Austin Ziegler wrote: > > On 15/12/05, Brad Daily <brad@bradleyboy.com> wrote: > >> My question is this: Is there a way to do this in PDF::Writer that I am > >> missing? If not, what is the best way to hook up LaTex to my rails app? > > > > Yes, there''s a way. No, it''s not "automatic" right now. If you''re > > interested in taking the steps necessary to make PDF::Writer do the > > right thing for labels, I''ll happily incorporate it into PDF::Writer. > > Otherwise, it will have to wait until I have time to do it. There are > > some examples in the open source world already (in other languages) on > > how to best do this, and as long as it''s under the PDF::Writer licence > > (essentially MIT-licensed, friendly to both open source and commercial > > interests), I''ll incorporate it. > > > > -austin > > -- > > Austin Ziegler * halostatue@gmail.com > > * Alternate: austin@halostatue.ca > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
* Rob Kaufman <rgkaufman@gmail.com> [2006-01-24 12:06]:> Has any progress / work been done on bringing easy label support to > PDF Writer?It''s not yet easy, but I''ve been making labels with PDF::Writer using Avery label information taken from Microsoft Word. I have a Label model, like this:>> Label.find(:first).attributes.each {|a| p a }["side_margin", 0.25] ["name", "Avery 05161"] ["label_height", 1.0] ["down", 10] ["across", 2] ["vertical_pitch", 1.0] ["label_width", 4.0] ["id", 1] ["horizontal_pitch", 4.19] ["top_margin", 0.5] Those measurements are in inches, for 8.5"x11" paper. lib/pdf.rb: require ''pdf/writer'' module PDF def self.labels(elements, label = Label.find(:first)) pdf = PDF::Writer.new pdf.margins_in(label.top_margin, label.side_margin) pdf.select_font ''Courier'' horiz_pitch = pdf.in2pts(label.horizontal_pitch) vert_pitch = pdf.in2pts(label.vertical_pitch) catch(:end_of_labels) do until elements.nil? do label.across.times do |x| label.down.times do |y| e = elements.shift or throw :end_of_labels pdf.y = pdf.absolute_top_margin - (y * vert_pitch) pdf.text e, :left => (x * horiz_pitch) end end pdf.start_new_page end end pdf.render end end I''m not sure if a catch/throw block is the nicest way to do that. In my subscriber controller, I have a labels method for making the pdf: def labels @subscribers = Subscriber.find_unexpired send_data(PDF.labels(@subscribers.map {|s| s.shipping_label.join("\n") }), :filename => ''windsor-review-subscriber-labels.pdf'', :type => ''application/pdf'', :disposition => ''inline'') end This is all pretty rough. It assumes that the lines on each label fit in the space (six lines of about 45 characters each). It does work, though. What information is in each gLabel template?