sasnaktiv
asked on
Creating a PDF via PHP and having sizing problems $mpdf
Hi Guys,
I'm trying to create a business card size PDF document.
My problem is that the content becomes small rather than fill the 3.5inch x 2inch PDF page. The content is just shrinking !!!
Does anybody know how to fix this problem?
Sas
PS: I also want it to either echo a "PDF Created" message or forward to a page, but that won't function either. But I may have to open another ticket for that.
I'm trying to create a business card size PDF document.
My problem is that the content becomes small rather than fill the 3.5inch x 2inch PDF page. The content is just shrinking !!!
Does anybody know how to fix this problem?
Sas
PS: I also want it to either echo a "PDF Created" message or forward to a page, but that won't function either. But I may have to open another ticket for that.
<?php
$pDate = date("m/d/Y");
$var1 = 'Company Address';
$content = '
<CENTER>
<table border=2 width="100%" height="100%" > <! ... without this outer table each element of the inner table becomes a seperate page ... -->
<TR><TD>
<!-- .... CONTENT .... -->
<table border=0 width="100%" height="100%" >
<TR><TD><center><img src="http://www.CompanyName.com/images/Logo_250.png" width=250 border=0 alt="Company Name"></center>
</TD></TR>
<TR><TD style="font-size:24px;font-family:ariel;"><center>GUEST CARD</center>
</TD></TR>
<TR><TD style="font-size:19px;font-family:ariel;"><center><B>'.$var1.'</B></center>
</TD></TR>
<TR><TD style="font-size:14px;font-family:ariel;"><center>Issue Date: '.$pDate.'</center>
</TD></TR>
<TR><TD align=right><BR> <BR><img src="http://www.ServicedBy.com/images/Logo_130.png" width=130 border=0 alt="ServicedBy.com">
</TD></TR></TABLE>
</TD></TR></TABLE>
</CENTER>
';
//==============================================================
//==============================================================
include("mpdf.php");
$mpdf = new mPDF('utf-8', array(87,50));
// LOAD a stylesheet
$stylesheet = file_get_contents('mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text
$mpdf->WriteHTML($content);
$mpdf->Output("GuestCard.pdf","D"); // Use D to output to the browser and force a download.
echo '<meta http-equiv="refresh" content="0;url=http://www.ExpertsExchange.com/">'; // For some unknown reason this does not forward.
exit;
//==============================================================
//==============================================================
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi guys,
Just an update. I'm still working on solving this.
I've been trying to make this thing function the way I want it to with limited success.
The input from lwadwell was helpful in restricting the size of the pdf page, but other problems are created.
Ray's input is a bit more complex and I'm having trouble executing it with my variables.
I need some time to work on these and I will post my accomplishments or failures as soon as I possibly can.
Thanks for all the help,
Sas
Just an update. I'm still working on solving this.
I've been trying to make this thing function the way I want it to with limited success.
The input from lwadwell was helpful in restricting the size of the pdf page, but other problems are created.
Ray's input is a bit more complex and I'm having trouble executing it with my variables.
I need some time to work on these and I will post my accomplishments or failures as soon as I possibly can.
Thanks for all the help,
Sas
ASKER
I'm not quite sure what's working & what's not.
lwadwell's solution works with the code I submitted.
Ray's is an entirely different approach which I have not been able to master.
So I'll be awarding the points the best way I can in order to be fair.
And since I've been pushing this, I've run into other challenges. But I think I'll have to open another ticket to address them.
Thanks for the help.
Sas
lwadwell's solution works with the code I submitted.
Ray's is an entirely different approach which I have not been able to master.
So I'll be awarding the points the best way I can in order to be fair.
And since I've been pushing this, I've run into other challenges. But I think I'll have to open another ticket to address them.
Thanks for the help.
Sas
Since this question, I have begun using TCPDF with very good results. Maybe worth a look. In any case, thanks for the points, ~Ray
ASKER
I'll kick this around in the morning. I've already tried www.fpdf.org but had trouble making it work with tables & variables. That's why I turned to mPDF53, which allowed me to incorporate the tables & variables but now it's giving me the size issue.
Sas