Subject: | Make "allow overflow" in PDF::API2::Content::paragraph configurable by option |
PDF::API2::Content contains the method paragraph wich calls
text_fill_left, text_fill_right, text_fill_center and text_fill_justified.
All these methods call the method _text_fill_line which itself has a
parameter "over" which controls if a word should be allowed to "spill
over" the bounds of the given paragraph width or if the word should be
in the next line.
This parameter is hardcoded and can not be changed.
I've created a patch which introduces a new option "-spillover" which by
default is 1 and corrsponds the current behaviour.
Setting this parameter to 0 holds the words strictly within the given width.
A patch against version 0.69 of Content.pm (fileversion 2.9) is attached .
Thank you for applying this patch.
Subject: | PDF-API2-Content.pm.diff |
--- Content.pm.orig 2008-01-18 11:31:07.247690000 +0100
+++ Content.pm 2008-01-18 12:15:08.767623000 +0100
@@ -1897,7 +1897,8 @@
sub text_fill_left
{
my ($self,$text,$width,%opts)=@_;
- my ($line,$ret)=$self->_text_fill_line($text,$width,1);
+ my $over=(not(defined($opts{'-spillover'}) and $opt{'-spillover'} == 0));
+ my ($line,$ret)=$self->_text_fill_line($text,$width,$over);
$width=$self->text($line,%opts);
return($width,$ret);
}
@@ -1911,7 +1912,8 @@
sub text_fill_center
{
my ($self,$text,$width,%opts)=@_;
- my ($line,$ret)=$self->_text_fill_line($text,$width,1);
+ my $over=(not(defined($opts{'-spillover'}) and $opt{'-spillover'} == 0));
+ my ($line,$ret)=$self->_text_fill_line($text,$width,$over);
$width=$self->text_center($line,%opts);
return($width,$ret);
}
@@ -1925,7 +1927,8 @@
sub text_fill_right
{
my ($self,$text,$width,%opts)=@_;
- my ($line,$ret)=$self->_text_fill_line($text,$width,1);
+ my $over=(not(defined($opts{'-spillover'}) and $opt{'-spillover'} == 0));
+ my ($line,$ret)=$self->_text_fill_line($text,$width,$over);
$width=$self->text_right($line,%opts);
return($width,$ret);
}
@@ -1939,7 +1942,8 @@
sub text_fill_justified
{
my ($self,$text,$width,%opts)=@_;
- my ($line,$ret)=$self->_text_fill_line($text,$width,1);
+ my $over=(not(defined($opts{'-spillover'}) and $opt{'-spillover'} == 0));
+ my ($line,$ret)=$self->_text_fill_line($text,$width,$over);
my $hs=$self->hspace;
my $w=$self->advancewidth($line);
if($ret||$w>=$width)
@@ -1973,6 +1977,14 @@
If a scalar, distance below baseline,
else array reference with pairs of distance and line thickness.
+=item -spillover => $over
+
+Controls if words in a line which exceed the given width should be "spilled over" the bounds or if a new line should be used for this word.
+
+Over is 1 or 0
+Default is 1
+
+
=back
B<Example:>