Thread Regex um Fließtext mit PDF::ReUse in Zeilen aufzuteilen
(1 answers)
Opened by capp at 2009-07-02 16:00
Ich benutze so etwas:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 sub _add_text { my ($x, $y, $text, $size) = @_; $size ||= 20; my @parts; while( $size < length $text ) { my $position = rindex $text, " ", $size; $position = $size if $position == -1; my $sub = substr $text, 0, $position; $text = substr $text, $position; push @parts, $sub; } push @parts, $text if length $text; for my $line ( @parts ){ $line = " " unless $line; prText( $x, $$y , $line ); $$y -= 15; } } Damit bin ich ziemlich flexibel. Aufruf: Code: (dl
)
1 my $x = 20; # Abstand vom linken Rand Ich übergebe hier eine Referenz auf $y, weil ich da nicht ständig was hin und her kopieren will. Die Überprüfung auf "\n" müsste man hier noch einbauen. Z.B. am Anfang schon an \n spliten und für jedes Element dann auf die Länge prüfen. OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |