/    Sign up×
Community /Pin to ProfileBookmark

Placing Image in PDF using PHP

Hi guys,
if you often use PDF as a report builder thru PHP, may be you can solve my problem.

I’m freshmen in this case, i use PDF to create a report (i use fpdf from [url]http://www.fpdf.org)[/url]. To show the data is not a big deal, but when i try to show the image of the data i become confuse. The data will stop when a page is added but the image won’t, they keep looping and one thing that confusing me a lot that why in the next page the images won’t show up, they only appear in the first page.

i use the script below and i attached the .pdf file as the result from the script below :

[COLOR=”Blue”]<?

require(‘fpdf.php’);
$conn = mysql_connect(‘localhost’,’root’,’root’);
mysql_select_db(“online_order_db”,$conn);

class PDF extends FPDF
{
function Header()
{
$this->SetFont(‘Arial’,’B’,9);
$this->SetFillColor(240,240,240);
$this->Cell(7,0.8,’Reff Code’,1,0,’C’,1);
$this->Cell(12,0.8,’Description’,1,0,’C’,1);
//$this->Cell(3,0.8,’Unit’,1,0,’C’,1);
//$this->Cell(5,0.8,’Price’,1,0,’C’,1);
$this->Ln(); // Ganti Baris
}

function Footer()
{
$this->SetY(-1.5);
$this->SetFont(‘Arial’,’B’,’9′);
$this->Cell(0,0.5,’Printed By : Arius’,0,0,’R’);
}
}

$pdf = new PDF(‘P’,’cm’,’Legal’);
$pdf->Open();
$pdf->AddPage();

$sql = “select * from product_tb order by id_product asc limit 0,40”;
$que = mysql_query($sql) or die(mysql_error());

$YPos = 2;
while($dt = mysql_fetch_array($que))
{

$pdf->Image(‘images/datascrip.jpg’,2.5,$YPos,4);
$pdf->Cell(7,2,”,1,0,’L’);
$pdf->Cell(12,2,$dt[‘IMAGE_LOW’],1,0,’L’);
$pdf->Ln();

$YPos = $YPos+2;
}

$pdf->Output();

?>[/COLOR]

Please Help Me
Thank You Very Much ?

[upl-file uuid=67f3fe4e-0113-44aa-9f98-01169b16dd4f size=5kB]doc1.pdf[/upl-file]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @baltazhor200401 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...