How to achieve this, like a horiz. align to center? I`m trying Prawn to generate PDFs, but having a problem to place a short text (3 words) at the horiz. middle of the page. This code places the text 2 or 3 centimeters right from the middle. Prawn::Document.generate(''public/'' + dir + "certificado.pdf", :page_size => "A4", :page_layout => :landscape) do bounding_box([0,430], :width => 800, :height => 600) do text nome, :size => 28, :align => :center end end As I change ":width => 800" value, the distance from the middle changes. I tried to remove width and heigth options, hoping the bounding_box to fit all the page, but I got a error. PS: I tried to subscribe to http://groups.google.com/group/prawn-ruby but it appears it is not accepting subscriptions. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sorry for responding to a very ancient post, I almost never read the Rails list... On Jan 6, 9:22 am, Tom Lobato <tomlob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> How to achieve this, like a horiz. align to center? > > I`m tryingPrawnto generate PDFs, but having a problem to place a > short text (3 words) at the horiz. middle of the page. This code > places the text 2 or 3 centimeters right from the middle. > > Prawn::Document.generate(''public/'' + dir + > "certificado.pdf", :page_size => "A4", :page_layout => :landscape) do > bounding_box([0,430], :width => 800, :height => 600) do > text nome, :size => 28, :align => :center > end > end > > As I change ":width => 800" value, the distance from the middle > changes. I tried to remove width and heigth options, hoping the > bounding_box to fit all the page, but I got a error.Get rid of the bounding box entirely and just do: text nome, :size => 28, :align => :center You were centering your text within the box, not within the page.> PS: I tried to subscribe tohttp://groups.google.com/group/prawn-ruby > but it appears it is not accepting subscriptions.Please re-subscribe. You probably missed the "Are you human" form field, which caused you to be denied. -greg --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hello Greg! at first, congratulations! very nice work! funny, today a tried again to subscribe to the prawn group and noted the "r u a human?" question. So I subscribed and returned here, in the rails talk, to copy my msg to there, then I saw you reply :) well, here we go... On 29 jan, 16:11, Gregory Brown <gregory.t.br...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Sorry for responding to a very ancient post, I almost never read the > Rails list... > > Get rid of the bounding box entirely and just do: text nome, :size => > 28, :align => :center > > You were centering your text within the box, not within the page.in really I tried this before, but got a different bad aligment problem. Also, I`m using bounding box to position my text. Is there another way to position text without bounding box? Moreover, if I keep using the bounding box, how to position it at exact center of the page? PS: when we close this thread, I will copy it digested to the prawn list. Thank you, Tom Lobato --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Solved! I had to use bounding box to position the text. The trick is to use the bounding_box parameters: :width => bounds.width, :height => bounds.height instead :width => 800, :height => 600 now prawn center the text exactly. See all the code... Prawn::Document.generate("Certificado.pdf", :page_size => "A4", :page_layout => :landscape) do bounding_box([0,430], :width => bounds.width, :height => bounds.height) do text name, :size => 28, :align => :center end bounding_box([0,180], :width => bounds.width, :height => bounds.height) do text "#{local}, #{date}", :size => 20, :align => :center end end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---