For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > September 2006 > Adding text, merge with 2nd pdf and upload it









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Adding text, merge with 2nd pdf and upload it
ccampise@gmail.com

2006-09-28, 7:59 am

Hello all-

I'm attempting to take two existing pdf files, add text to them, merge
them into 1 single pdf, then stream that pdf to a browser allowing the
user to download the modified-single file.

I have no problem when adding text to a single document, and then
streaming that. The text shows up correctly in the downloaded pdf.

The problem is when I add text to > 1 document, merge them into a
single document, and stream the single document. The downloaded pdf
file doesn't contain any of the text I added, although it does merge
them correctly.

My current code :

sub stream {
my $self = shift;

my $dest_pdf_filename = "my_first.pdf";
my $source_pdf_filename = "my_second.pdf";

my $source_pdf = PDF::API2->open( $source_pdf_filename );
my $dest_pdf = PDF::API2->open( $dest_pdf_filename );

my $page = $source_pdf->openpage(1);

$page->text->textlabel(
60,
681,
$source_pdf->corefont('Arial'),
45,
'TEST');

$dest_pdf->importpage( $source_pdf, 1);

my $cgi = new CGI;

print $cgi->header(
-type => "application/pdf",
-attachment => "forms.pdf",
);

$dest_pdf->stringify;

return;
}

Any thoughts or ideas on this would be greatly appreciated!

Chris

Michele Dondi

2006-09-28, 7:59 am

On 28 Sep 2006 05:44:32 -0700, ccampise@gmail.com wrote:

>I'm attempting to take two existing pdf files, add text to them, merge
>them into 1 single pdf, then stream that pdf to a browser allowing the
>user to download the modified-single file.


I know this is clpmisc, but how 'bout using LaTeX with the pdfpages
package? (Hence xposted to ctt!)


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{po
p^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com