I am using pdflib to create selected documents for my users. When the document is created I would like to store some tracking information about the document in my database. The problem is everytime a document is created the database code is run twice. It makes no difference where my db code is located in the script as the entire script appears to run twice. Is this pdflib issue or something I can correct?
Here is some sample code of what I am trying to do:
$pdf = pdf_new();
pdf_open_file($pdf);
//Get the fonts you will need
$times = pdf_findfont ($pdf, "Times-Roman", "winansi");
// Create the page.
pdf_begin_page ($pdf, 612, 792);
pdf_setfont ($pdf, $times, 24);
pdf_show_xy($pdf, "Table of Contents", 72, 700);
pdf_end_page($pdf);
pdf_close($pdf);
$buffer = pdf_get_buffer ($pdf);
//Begin Output
header ("Content-type: application/pdf");
header ("Content-Length: " . strlen($buffer));
header ("Content-Disposition: inline; filename=filename.pdf");
echo $buffer;
// Free the resources
pdf_delete ($pdf);
//Store tracking info
$db = dbConnect();
$sql="Insert into scratch (scratch) values ('pdf creation complete')";
$result = mysql_query($sql);
Whenever this is run the pdf opens correctly on the screen but there are two records created in the scratch table with value "pdf creation complete". I am wondering if the process of opening acrobat in IE causes the page to load twice.