Re: Binary output

Jeremy Blain <[email protected]>
Newsgroups gmane.comp.web.mason.devel
Message-ID <[email protected]>
My first thought, would be that it is sending the data correctly,
but maybe with incorrect headers, or the browser isn't interpreting
them correctly.

Try adding
$r->content_type('application/pdf');

Serge Sozonoff wrote:

> Hi all,
>
> I am trying to push a PDF file out using $m->print() but for some 
> reason it is getting mangled. I have read some of the documentation 
> about this on the site and tried the suggestions but it just does not 
> work.
> If I write the data using the $pdf->saveas method the PDF output is 
> fine. It seems that somwewhere along the way when using $m->print() 
> binary data is getting modified. When I compare the two files the 
> ASCII stuff all looks the same.
>
> Any thoughts or comments ?
>
> Thanks,
> Serge
>
> Example code below:
>
> <%init>
>
> use PDF::API2;
>
> my $pdf  = PDF::API2->new();
> $pdf->mediabox(595,842);
> my $page = $pdf->page;
> my $fnt = $pdf->corefont('Arial',-encoding => 'latin1');
> my $txt = $page->gfx;
> $txt->textstart;
> $txt->font($fnt, 20);
> $txt->translate(100,800);
> $txt->text("Hello World! left-aligned");
> $txt->translate(500,750);
> $txt->text_right("Hello World! right-aligned");
> $txt->translate(300,700);
> $txt->text_center("Hello World! center-aligned");
> $txt->textend;
> $m->clear_buffer;
> $m->print($pdf->stringify());
> $pdf->end;
> $m->abort;
> </%init>




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.