Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using PerlScript with ASP and PDF::API2 to create PDFs

Status
Not open for further replies.

tfomsu03

Programmer
Joined
Jun 27, 2006
Messages
5
Location
US
I'm having a problem, which I'm sure has a very simple answer. I actually copied this code from the CPAN howto on the PDF::API2 module. Here's my ASP code:

<%@Language="PerlScript" %>
<%
use strict;
use Win32::ASP qw(:strict);
use PDF::API2;
use warnings;

my $pdf = PDF::API2->new();
my $fnt = $pdf->corefont('Helvetica-Bold');
my $page = $pdf->page;

$page->mediabox('A4');

my $gfx = $page->gfx;
$gfx->textlabel(200,700,$fnt,20,'Hello World !');

$pdf->saveas('document.pdf');
$pdf->end;
%>

<html>
<head>
<title> HelloWorld PDF </title>
</head>
<body>
The helloworld pdf should be generated now.
</body>
</html>

I'm brand new to these forums, so I don't know how it will take the HTML tags I included above, but if for some reason they don't show, I basically have a very simple 8 line HTML document under my closing ASP tag.

The PDF file is not created, and I get this error when trying to view the file on the webserver:

PerlScript Error error '80004005'

(in cleanup) Unable to open document.pdf for writing at C:/perl/site/lib/PDF/API2/Basic/PDF/File.pm line 511.


Any help is appreciated.
 
Unable to open document.pdf for writing at C:/perl/site/lib/PDF/API2/Basic/PDF/File.pm line 511.

Looks like a permissions error, try adding this to the line
Code:
$pdf->saveas('document.pdf') [COLOR=red]or die "It carked .. $!\n";[/color]

HTH

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I'm still getting the same error.
 
After typing a full path to the file, I'm getting it to show the die() error message.
 
Strange turn of events... When I use the full path to the file, as well as the or die("$!") I get the error message:
"Bad File Descriptor". But for some odd reason, it creates the PDF correctly. I have no idea what the hell is going on lol.
 
Is there a file already in place, that you're overwriting? I'm officially clutching at straws here ...

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top