[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] OT: PDF::API2 help!


Eric Olson wrote:

I had looked at this, but was having problems getting HTML::HTMLDoc from
cpan. This is what I needed here. Are you familiar with how to pass the
pdf created by this into the browser?

Well, I'm not using HTML::HTMLDoc ... just doing it behind the scenes w/ that system() call. Once the file is done, if you wanted to pass this into the browser, you could open() the file and read the bits into an $output variable and return that in your runmode. Or you could trigger a download like so:

sub my_runmode {
  # ...
  $self->header_props(
      -type	=> 'application/octet-stream',
      -attachment	=> "$filebase.pdf",
    );
  # gather up $output
  return $output;
}

Don't forget to clean up after yourself by unlinking the pdf file.

Also, how is this module for handling images in the pdf. I have two .png
graphe created by GD::Graph I need to place in the body of the pdf. Can
this module handle that? Sorry for asking without looking at the module,
deadline and all.....

Hmm, again, I would put the images and everything into that HTML::Template, create a dummy HTML file and let htmldoc do the rest.

Expanding that:

sub my_runmode {
  # Generating png files, writing the files in the same temp directory
  # as the soon-to-be html template file
  $template->param( 'graph1' => 'graph1.png' );
  # You see, in your template file, you'd have something like
  # <img src="<!-- tmpl_var name="graph1" -->" ...>
  $html = $template->output();
  open( FILE, ">/temp/dir/output.html" );
  print FILE $html;
  close ( FILE );

  # ...
  $self->header_props(
      -type	=> 'application/octet-stream',
      -attachment	=> "$filebase.pdf",
    );
  # gather up $output
  return $output;
}

HTH,

Jason

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.