Hi Monks! I am developing small system in HTML::Mason and as a part of it - trying to generate PDFs and display/print it. I wanted WWW page to open generated PDF in separate Acrobat window, but didn't succeeded.
Didn't know how to do it, tried with 'system'. From command line system("C:/<properpath>/AcroRd32.exe", "mypdf.pdf") is working, from WWW it isn't (no error is displayed, no new Acrobat window). I started scanning Perlmonks, but it seems everyone wants to display PDF in browser's window/tab (e.g. Opening PDF through CGI). OK, this form suits me too. I digged through Mason's documentation and found proper code and the only problem that remains is: how to open PDF in browser's new tab/new window instead of current one? Here is the code of some HTML page:
% if($ddc_generatePDF) % { <& '/pdf_templates/generatePDF.html', data => $data, data2 => $data2, fileName => 'D:/project1/printouts/mypdf.pdf' &> <& '/pdf_templates/displayPDF.html', fileName => 'D:/project1/printouts/mypdf.pdf' &> % }
Here code of generatePDF.html
<%args> data data2 fileName </%args> <%init> use constant mm => 25.4/72; use constant in => 1/72; use constant pt => 1; </%init> <%perl> PDF::Reuse::prFile($fileName); ...some other commands... PDF::Reuse::prEnd();
Here, code of displayPDF.html:
<%args> $fileName </%args> <%init> use Apache2::SubRequest; my $subr = $r->lookup_file($fileName); return 404 unless -f $fileName and $subr->status == 200; $r->content_type($subr->content_type); # $r->send_http_header; return 200 if $r->header_only; $subr->run; $m->abort; </%init>
Any help appreciated. And virtual beer for one more hint: how to open print dialog programmatically after displaying PDF?

I am working on Win XP, but it will be installed on Linux.


In reply to Open generated PDF in new tab/new page in HTML::Mason by grizzley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.