Every repository with this icon (
Every repository with this icon (
| Description: | Fast, Nimble PDF Writer for Ruby edit |
-
It would be very convenient to a project I'm doing if it were possibly to do, e.g.
pdf.cell blahblah, :vertical_align => :center
and have that work as easily as :horizontal_align => :center does. You can "fake it" with vertical padding fairly easily... right until you end up word wrapping.
I'm currently banging my head against this for my project but if I get a generalizable solution working I'll try getting you guys the code.
Comments
-
(Note: I've replaced this ticket with a different description --greg)
See http://github.com/rogergl/prawn/commit/5f11d7701e9b63c62d6b7ad3922a3029740f2344 for a reference implementation, but we really should centralize our alignment hackery so we don't repeat this same basic procedure again and again
Comments
-
0 comments Created 1 day ago by sandal1.0xtext_box should support font options (size, style, etc)requestxComments
-
4 comments Created about 1 month ago by jontebol1.0xrequestxrounded_rectanglewould_be_nicexI have looked through the PDF-reference and can't find a way to do rectangles with rounded corners at the PDF-level, so it seems this should be done like PDF-writer did it, by drawing lines and curves.
A working method was submitted by Benjamín Cárdenas Salamandra in this thread:
http://groups.google.com/group/prawn-ruby/browse_thread/thread/9505ce1a5fade296Here it is again:
def rectangle_rounded(point,width,height,radius) x,y = point line [x+radius,y],[x+width-radius,y] line [x+radius,y-height],[x+width-radius,y-height] line [x,y-radius],[x,y-height+radius] line [x+width,y-radius],[x+width,y-height+radius] l1 = radius * KAPPA y1 = y-radius+l1 x1 = x+radius-l1 x2 = x+width-radius+l1 y2 = y-height+radius-l1 curve [x,y-radius],[x+radius,y], :bounds => [[x,y1],[x1,y]] curve [x+width-radius,y],[x+width,y-radius], :bounds => [[x2,y],[x+width,y1]] curve [x+width,y-height+radius],[x+width-radius,y-height], :bounds => [[x+width,y2],[x2,y-height]] curve [x+radius,y-height],[x,y-height+radius], :bounds => [[x1,y-height],[x,y2]] endUPDATE: This method works well for stroked rounded rectangles, but not if you fill it. I'm working on an implementation that works for both cases, but haven't finished it yet.
Comments
Here is a page that describes several implementations of rounded rectangles for cairo which is a vector library with primitives like pdf
Definitely will accept a patch for this, but it needs to be on a fork with tests and examples
Definitely will accept a patch for this, but it needs to be on a fork with tests and examples
Question about this:
When I was making my star shape the other day, I wondered how one would write specs for it. The spec for, as an example, ellipse_at in the Prawn spec suite does test that the API hasn't changed, and that the pointer is back at the center of the ellipse, but it doesn't really test that an ellipse has been drawn, just the last point.I guess one could create an example, render it, go into the resulting PDF and extract the generated points, and then create a regression test spec.
Do you have guidance on this, Greg?
Thank You,
Daniel
-
2 comments Created 7 months ago by sandal1.0xpdf-writerxTweak Document#text_box to implement some features from PDF::Writer#add_text_wraprequestxThis is a request for several enhancements to Prawn#text_box so that it would support the features of #add_text_wrap in PDF::Writer.
When Prawn#text_box is called with the :truncate or :ellipses option the text which is not displayed in the text box is returned. (Implemented by geeksam and merged for 0.6)
When Prawn#text_box is called with the :angle => (int in range 0..259) option, the text is rotated as it would be using PDF::Writer #add_text_wrap
When Prawn#text_box is called with the :justification => :left | :center option, the text is justified as it would be using PDF::Writer #add_text_wrap
Comments
-
0 comments Created 5 months ago by sandalrequestxmaybe make span and bounding box API compatible?would_be_nicexPOLS?
Comments
-
3 comments Created 3 months ago by expilorequestxAdd DeviceN colorspace supportwould_be_nicexThis is a prerequisite for a project aimed at creating a duotone tool in ruby. Necessary for all documents using spot colors. BTW I guess there is no reason why Prawn should not support all the remaining colorspaces that PDF offers.
Comments
Patches welcome. This isn't on the critical path but I'd be fine accepting a patch for it as long as it was reasonable. This won't get done by me though, in the foreseeable future.
-
As someone else mentioned on the list, support for configuring letter spacing would be nice.
Comments
I noticed prawn-format has some support for this. You can add something like
if options[:letter_spacing] state[:text].character_space(options[:letter_spacing]) endto Line#draw_on and then do something like
text "foo", :letter_spacing => 123, but this messes up line wrapping and likely a bunch of other things.
Maybe someone can build on it, though.
Patches are welcome for this feature but they need to be well tested and come with examples.
If it helps someone else, I ended up faking it (in Rails, hence the
chars) like this:require "prawn/format" my_string = "some text\nsome more" spaced_string = my_string.lines.map {|line| line.chars.split('').join('<space></space>') }.join('<br/>') text spaced_string, :tags => { :space => { :width => '1' } } # fake letter-spacing -
Comments
-
1 comment Created 3 days ago by henrik1.0xwidth_of should respect :stylewould_be_nicexwidth_of gives the same results with or without :style. Would be nice if it gave actual results for :style => :bold or :style => :italic.
Measuring width_of for text bolded with <b> in prawn-format works fine (well, in 0.5.1, see http://github.com/sandal/prawn-format/issues/#issue/13), so there may be code for this already.
Example:
require "rubygems" gem 'prawn-core', '=0.5.1' gem 'prawn-format', '=0.2.1' require 'prawn/core' require "prawn/format" Prawn::Document.new do text "hello is #{width_of("hello")} wide" # 25.344 text "hello is #{width_of("hello", :style => :bold)} wide", :style => :bold # 25.344 text "<b>hello is #{width_of("<b>hello</b>")} wide</b>" # 28.008 text "<b></b>hello is #{width_of("<b></b>hello")} wide" # 25.344 render_file '/tmp/example.pdf' end `open /tmp/example.pdf` # OS XTo clarify, I'm using 0.5.1 because prawn-format's width_of is broken in 0.6.2. width_of with :style still doesn't work in 0.6.2:
require "rubygems" gem 'prawn-core', '=0.6.2' gem 'prawn-format', '=0.2.2' require 'prawn/core' require "prawn/format" Prawn::Document.new do text "hello is #{width_of("hello")} wide" # 25.344 text "hello is #{width_of("hello", :style => :bold)} wide", :style => :bold # 25.344 text "<b>hello is #{width_of("<b>hello</b>")} wide</b>" # 70.056 text "<b></b>hello is #{width_of("<b></b>hello")} wide" # 70.056 render_file '/tmp/example.pdf' end `open /tmp/example.pdf` # OS XComments
Oh, at first I thought this was a bug report. Yes, this would be nice. Go ahead and code up a patch for it with some tests for it. Or we'll eventually get to it before 1.0.
The reason width_of() works for inline styles is because it has to in order for other features to work. But that doesn't mean it's not a good idea to make this work, too.











