Creating a custom sized PDF
Micah:
I have successfully managed to modify your code so that I can create a custom sized PDF with my own variable text, but I need to also specify a background colour, rather than import an image. I have looked at the PDF listing and tried every modification I can think off, but I still haven't succeeded.
Do you any clues to enable me to specify the RGB values as three variables (or even an array) at the start of the code?
Many thanks
Ian
A solution ... sort of
Micah:
After going through your links I realised I need to add SetFillColor and Rect to the end of the code. I've already defined the page to be 800 wide and 600 deep and this works just fine. I then used the x,y coords of 0,0 and gave my rectangle a width of 800 and a height of 600. The fill is a nice purple! However, no matter what I do I just cannot get the PDF to print out with the rectangle at 600 ... it just stops half-way. Have you any idea what I might be doing wrong? I've tried adding margin settings to no avail. I'm baffled! Here's a listing of the relevant lines of code:
$pdf = new cPdfWriter();
$pdf->AddPage();
$pdf->SetFillColor(100, 100, 200);
$pdf->Rect(0,0,800,600,'F');
$pdf->SetFont($font, $style, $size);
//$pdf->Image('http://www.scodigo.com/images/scodigo_logo.gif', 10, 10, NULL, NULL, GIF, 'http://www.scodigo.com/');
$pdf->Cell(0, 10, $text_1, 1, 1, 'L');
$pdf->Cell(0, 10, $text_2, 1, 1, 'L');
$pdf->Output($file_path, 'F');
Cheers
Ian
Fixed ... weird but it works now!
Micah: I managed to finally get the results I wanted by multiplying the width of the rectangle by a factor of 2.83464567 which is the figure needed to convert mms to pts. Strange that I didn't have to do it to the height, though!
Anyhow, another issue has raised its ugly head which is really confusing me. I'm using version 2.0.1 of the plug-in and testing out my script using your testbed. Strangely, the PHP constant FM_DESKTOP_PATH isn't recognised by the plug-in, but DESKTOP_PATH is!
Also when I create a new FM database and try to use the constant neither FM_DESKTOP_PATH nor DESKTOP_PATH works and I just get '?' returned.
Have you any thoughts on what might be going on here? I'm using both FM 10 and 11 Advanced and OS X 10.6.2, and this happens regardless of whether I use 10 or 11.
Cheers
Ian
Fixed ... weird but it works now!
Hello Ian,
Glad you got the conversion figured out!
Hmmm, in regards to the problem with the path constants, I don't know what's going on there. I have some test code I use for these as follows and they work fine in 11 for both Mac and Win.
echo FM_DESKTOP_PATH . "\n";echo FM_DOCUMENTS_PATH . "\n";
echo FM_EXTENSIONS_PATH . "\n";
echo FM_PHP_SUPPORT_PATH . "\n";
echo FM_PHPX_PATH . "\n";
echo FM_PREFERENCES_PATH . "\n";
echo FM_TEMPORARY_PATH . "\n";
//New in 2.0.1
echo FM_FILEMAKER_PATH . "\n";
I would expect DESKTOP_PATH to return a PHP notice like this:
PHP Notice: Use of undefined constant DESKTOP_PATH - assumed 'DESKTOP_PATH' in Embedded code on line 1Getting a ? return usually means the plug-in isn't loaded. You might give this a try in the Testbed.fp7 file that's included with the download and see if you can replicate your issue there. Let me know...
Regards,
Micah
Specifying background color for PDF
Hello Ian,
Are you looking at the cPdfWriter example? I don't have much experience with this so it'd take a bit of work to figure this out. My guess is that it can be done. You might look here for more info:
http://www.palos.ro/2006/12/20/cpdfwriter-library/
http://www.fpdf.org/
Regards,
Micah
Hello Micah: Yes, I was
Hello Micah:
Yes, I was looking at the cPdfWriter code. I'm sure it's doable, but there's such a lot of code there to wade through.
I'll look at the two links you've included.
Cheers
Ian