Click here to Skip to main content
16,019,957 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Stored an pdf file to varbinary field in Sql Server successfully and retrieved it as it is but my problem now i have to pass it to fpdi as source file please help me


Thanks

What I have tried:

<?php
require_once('fpdf/fpdf.php');
require_once('fpdi/fpdi.php');
require_once('connectionphp');
 
$strSQL = "SELECT * FROM files WHERE FilesID = '".$_GET["FilesID"]."' ";
 
$objQuery = sqlsrv_query($strSQL) or die ("Error Query [".$strSQL."]");
 
$objResult =sqlsrv_fetch_assoc($con,$objQuery);
 
header("Content-Type: ".$objResult["FilesType"]);
 
$pdf = new FPDI();
 
$pdf->AddPage();
 
$pdf->setSourceFile($objResult["FilesName"]);
//here $objResult["FilesName"] is the varbinary field extracted from database
 
$tplIdx = $pdf->importPage(1);
 
$pdf->useTemplate($tplIdx, 10, 10, 100);
 
$pdf->SetFont('Helvetica');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'I tried it');
 
$pdf->Output();
?>
Posted
Updated 19-Jun-17 22:25pm

1 solution

You should use setSourceFile in a different way (via stream)...
There is an article with a solution here:
Using a pdf from a php variable instead of a file | FAQ: Miscellaneous | Setasign[^]
 
Share this answer
 
Comments
Raghu112 20-Jun-17 7:01am    
Thank you :) it Helps me lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900