i'm just feeling that my head will explode unless someone help me with this problem:
I have stored a pair of TIFF images (related by a common key) for each one of almos 100.000 registries. And I create a PHP script that receives a key and echo the tiff image, so the browser return the tiff image:
<?php
// Determine the primary key to relate with the image table
$numero_registro = $_GET['numero_registro'];
$imagen = $_GET['imagen'];
if ($numero_registro != "")
{
$con = mysql_connect("localhost","XXXXX","XXXXXX");
if (!$con)
{
die('Problems with db: ' . mysql_error());
}
mysql_select_db("XXXXX", $con);
$result = mysql_query("SELECT img FROM image_table i WHERE i.fk_civil_registry_code = $numero_registro");
$i = 1;
while($row = mysql_fetch_array($result) )
{
if ( $imagen == $i )
{
#img is a long blob field
$ext="tiff";
header("Content-type: image/{$ext}");
echo $row['img'];
}
$i++;
}
mysql_close($con);
}
?>
This just works and the tiff image is displayed by the browser. But, this is a tiff image, so is displayed lonely (and viewed using alternaTiff). Until know this was no problem, cause I just needed to print a single image. But now my boss buy a big automatic duplex printer, and put it on his office, so I need a way to generate a pdf (of two pages) and put both images (echo $row['im开发者_Go百科g'];) each one on a single page, so they can print the PDF.
Can anyone help me to do that?
Thank you very much.
So you want to generate a 2-page PDF which consists of a tiff image on each page?
Perhaps the following links will be of interest:
http://www.fpdf.org/
http://kevin.vanzonneveld.net/techblog/article/php_tiff2pdf/
Then you can just flush the PDF to the browser.
Are you stuck with PHP? If you can work with ASP.NET, my company has a set of tools that will display and print TIFF images from AJAX controls as well as code that will generate self-printing PDF files. If you did the latter, you could keep your web work in PHP and hook up to a .NET service that takes N tiff files and generates a single printable PDF.
To give you a sense of what that would look like, the C# code to take two tiff images and convert to PDF would be:
FileSystemImageSource images = new FileSystemImageSource(pathToTiff1, pathToTiff2);
PdfEncoder encoder = new PdfEncoder();
encoder.CreateSelfPrintingPdf = true;
encoder.Save(outputStream, images, null);
Instead of a pdf document you could also use an html document with page-break-before css properties. e.g. try
<html>
<head><title>...</title></head>
<body>
<div><img src="http://sstatic.net/so/img/logo.png" /></div>
<div style="page-break-before:always;"><img src="http://sstatic.net/so/img/logo.png" /></div>
</body>
</html>
and then go to the print preview in your browser.
精彩评论