Cameron Ingram wrote:
> Hi I am very new to FOP.
>
> I am trying to display images that are stored in our database ,not on
> the disk, in a PDF. I found one response on the mailing list that
> suggested creating a custom URL handler.
That's how I do it, and I have it working happily. Here's some sample
code that may help you.
In the XSLT, we do the image like so:-
=============
<xsl:variable name="InstID" select="Database/InstID"/>
<xsl:variable name="StaffID" select="Database/StaffID"/>
<xsl:variable name="ImageURI"
select="concat('http://services.acu.ac.uk/cgi-bin/photo.pl?instid=',
$InstID,
'&staffid=',
$StaffID
)"/>
.....
other XSLT code
.....
<fo:block text-align="center">
<fo:external-graphic space-before.optimum="10pt" scaling-method="auto"
scaling="uniform" height="150pt">
<xsl:attribute name="src">
<xsl:value-of select="$ImageURI"/>
</xsl:attribute>
</fo:external-graphic>
</fo:block>
=============
The script that actually extracts and serves the image connects to an
Oracle database. I've omitted the subroutine that does the db
connection, but you get the idea:-
$dbh = dbConnect($database,$username,$password); # Connect to database.
$dbh->{RaiseError} = 1; # Die on db errors.
$q = new CGI;
$instid = $q->param('instid');
$staffid = $q->param('staffid');
$dbh->{LongReadLen} = 512 * 1024; # 512KB max - field max is 16M
$sth = $dbh->prepare("select " .
" staffbdphotograph " .
"from " .
" dbosc.tbl_staffbdphoto " .
"where " .
" instidctr = ? and " .
" staffid = ? ");
$sth->bind_param( 1, $instid);
$sth->bind_param( 2, $staffid);
$sth->execute();
($data) = $sth->fetchrow_array;
if ($data) {
print $q->header(-type=>'image/jpeg');
print $data;
} else {
open (BLANK_PHOTO, "supply_photo.gif") ||
die "Unable to find photo template!\n";
print $q->header(-type=>'image/gif');
undef $/;
$data = <BLANK_PHOTO>;
print $data;
}
We have a stock image that we serve where we don't have an appropriate
photo, but the rest is pretty generic.
HTH,
Mike.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]