Print labels in PDF [message #1744] |
Mon, 20 October 2008 12:37 |
bonzo_bcn
Messages: 152 Registered: June 2008
|
Senior Member |
|
|
I need to print a personal card for each person in a table.
Each A4 paper has 10 'boxes' divided into two columns of five elements. Each box will contain one persons data such as name, surname etc.
Is it possible to print a pdf with this format in radicore?
|
|
|
|
|
Re: Print labels in PDF [message #1747 is a reply to message #1746] |
Mon, 20 October 2008 15:08 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
If you take a look at the _cm_output_multi() method in radicore/xample/classes/x_person.class.inc you will see that the output is an array which may contain data from as many different records as you like. It is not restricted to one record per line - you can have multiple records on a single line as well as multiple lines for a single record. It all depends on what you put in the output array.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Print labels in PDF [message #1749 is a reply to message #1748] |
Tue, 21 October 2008 06:04 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
If you want to print 2 labels per line then you need to define a line containing 2 labels, then output an array containing as many lines as necessary.
Take a look at http://www.tonymarston.net/php-mysql/output-to-pdf.html#exam ple.invoice which is produced from radicore/xample/classes/x_person_s04.class.inc. The INVOICE_TO and SHIP_TO boxes show how you can print two address labels on a single line, but to get multiple lines you need to look at the production of the item lines in the _cm_output_multi() method for the 'multi1' condition. There you can construct an array containing as many lines as you need before you return.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
Re: Print labels in PDF [message #1750 is a reply to message #1744] |
Tue, 21 October 2008 08:14 |
bonzo_bcn
Messages: 152 Registered: June 2008
|
Senior Member |
|
|
Ok, more or less I got it.
Now I have problems printing the persons image in each label.
It seems as if there can only be one image per line.
If I put two images per line I get this error:
Fatal Error: Image file has no extension and no type was specified: fotos/firma (# 256).
Error in line 369 of file '/Applications/MAMP/htdocs/radicore/includes/std.pdf.class.inc'.
Script: /Radicore/ceae/fichas(output3).php
Any ideas on how to solve it?
[Updated on: Tue, 21 October 2008 09:08] Report message to a moderator
|
|
|
Re: Print labels in PDF [message #1751 is a reply to message #1750] |
Tue, 21 October 2008 09:24 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
That error message is saying that when it comes to process the image it is looking for an extension such as '.jpg' or '.png' to identify the file type, but cannot find one. What is the value for 'pic1' and 'pic2' in your data array? It should be a string containing the name of the image file.
I have tried running 'person_output(pdf)2.php' in the XAMPLE application which includes an image, and I can successfully resize it by changing the values for 'imagewidth' and 'imageheight' in the $fieldspec array without any problem whatsoever. Can you step through with your debugger to see where it is getting the values that it is using?
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
Re: Print labels in PDF [message #1755 is a reply to message #1753] |
Tue, 21 October 2008 11:00 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
The file name cannot be omitted with the current release, but I've updated my code to make this possible. Please see the attached file. You have two choices:
(1) Insert into the $fieldspec array for the image.
(2) Insert into the report struture file for the image.
Please note that the attached file contains ALL pending updates, so please read the notes in radicore/radicore-2008-xx-xx.txt
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Print labels in PDF [message #1761 is a reply to message #1744] |
Tue, 21 October 2008 14:37 |
bonzo_bcn
Messages: 152 Registered: June 2008
|
Senior Member |
|
|
I almost done, just one last thing:
The user filters the persons to be printed in the list1 transaction, from there a button prints the details of each person, but I've modified _cm_output_multi so that with the first call to _cm_output_multi, all the selected labels are printed in pairs.
Therefore what I'm getting right now is that all the labels are printed as many times as records are selected in list1.
So what I've done is define a variable called 'first_print=true' in the person class, and then:
function _cm_post_fetchRow ($rowdata){
if ($this->first_print){
$this->first_print = false;
return $rowdata;
}else{
return null;
}
}
Is this the correct way to achieve it?
[Updated on: Tue, 21 October 2008 14:45] Report message to a moderator
|
|
|
|