You have carriage returns before and after <% $output %> which could be
messing up your pdf, and which would definitely mess up a gif or jpeg.

Try putting the output inside the <%init> section and abort when you are
done, like this:

<%init>
# ...  generate pdf  ...
$r->content_type('application/pdf');
$m->clear_buffer;
$m->print($output);
$m->abort;
</%init>

~ John Williams


On Tue, 11 Jul 2006, J Cook wrote:

> Hi,
>
> I have a module that generates a pdf file on the fly that I want to use
> with Mason. So I have a directory named /pdfs and a dhandler that looks
> like:
>
> <%init>
> my $file_name = ($r->filename =~ /.*?\/pdfs\/(.*?)\.pdf/gi);
> $r->content_type('application/pdf');
> my $output = generate_pdf($file_name);
> </%init>
>
> <% $output %>
>
> <%flags>
> inherit => undef
> </%flags>
>
> And I have in httpd.conf I have:
>
>   <FilesMatch "(\.html|.pdf)$">
>     SetHandler  perl-script
>     PerlHandler MyApp::Mason
>   </FilesMatch>
>
> First off the file_name must match a database row, so generate_pdf can
> use that info to make the pdf. So when I call something like:
>  http://example.com/pdfs/12345.pdf
> I want to see a pdf pop up, but all I get is a 404 'Not Found' error. On
> masonhq.com in the FAQs I read:
>
> "Use mod_perl's $r->content_type function to set the appropriate MIME
> type. This will allow you to output, for example, a GIF file, even if
> your component is called dynamicImage.html."
>
> Does this mean that Mason cannot serve a pdf file that is generated on
> the fly like this? Do I need to name it with a .html extension and hope
> this doesn't break in certain browsers? Or is it something in my code
> above that is wrong?
>
> Justin
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Mason-users mailing list
> Mason-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mason-users
>



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to