Please note that the project is PDF::Writer; there is another simple
writer out there that someone else wrote called PdfWriter.
On 10/25/05, Nick Brutyn
<brutyn_nick-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>
wrote:> hey i want to do something like this
>
> pdf.text "testing\nOK"
>
> but also with the width
>
> cuz this is my text and the witdh must be 120 px;
I think you mean "120pt"; px have no meaning in PDF documents. The
standard unit of measurement is the point, which is about 1/72 of an
inch.
Note that there''s a known issue where the width of
''\n'' is being counted
as the width of ''M'' in the current font. THe forthcoming
PDF::Writer
1.1.4 will be fixing that and a couple of other reported problems.
You probably want to look at using PDF::SimpleTable (provided as part of
the whole PDF::Writer package). Otherwise, look at using the multicolumn
output and changing your margins to limit output to 120pt wide while
you''re writing.
Something like (untested, by the way):
2.times do |rows|
2.times do |cols|
memo = "Deze code wordt gebruikt in het kader van de "
memo += "kwaliteitscontrole rond de onderhoud - en/of "
memo += "schoonmaakactiviteiten van de firma: ghjghj\n"
memo += "Voor meer informatie kunt u ons bereiken op "
memo += "het nummer:\nghjghj\n"
lm = pdf.left_margin
rm = pdf.right_margin
pdf.left_margin = 80 + (cols * x)
pdf.right_margin = pdf.left_margin + 120
pdf.y = rows * (pdf.page_height / 2)
pdf.text memo
end
end
> y() => converts the coord, normal from the bottom, i prefer the top ;)
This is one where I simply have to disappoint. PDF works such that the
default origin coordinate (0, 0) is in the lower left hand corner. All
of my code is based on that. When drawing things (including text), you
*can* do an axis translation (documented in the graphics chapter), but
you are wholly responsible for coordinate positioning at that point.
Still, for a business card type of output, you''re probably better off
with something like PDF::SimpleTable.
-austin
--
Austin Ziegler * halostatue-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
* Alternate: austin-/yODNl0JVVCozMbzO90S/Q@public.gmane.org