PDF - horizontal line in title zone [message #5631] |
Tue, 14 June 2016 10:42 |
htManager
Messages: 433 Registered: May 2014
|
Senior Member |
|
|
Can I output a horizontal line in the title of a report and if yes, how?
I tried the following: I defined a (calculated) cell and want to show the 'Bottom' border but I don't succeed. Is there a different possibility?
Here is the code:
// define contents of page title
$structure['title'][] = array('text' => '%%datum_output',
'width' => 190,
'border' => 'b',
'newline' => 'y');
|
|
|
Re: PDF - horizontal line in title zone [message #5632 is a reply to message #5631] |
Wed, 15 June 2016 06:20 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I have done this in one of my outputs. Here is the code I used:
$structure['title'][] = array('text' => '',
'style' => 'rule',
'width' => '100%',
'y_relative' => 2.5,
'newline' => 'y');
This is what I had in my pdf.styles.inc file:
$style['rule']['font'] = array('family' => 'Times', // Courier, Helvetica, Times
'style' => '', // blank=Regular, B=Bold, I=Italic, U=Underline
'size' => 1.75, // size in points
'height' => 0.75, // line height in units
'draw' => 0); // width of drawn lines
$style['rule']['fillcolour'] = array(113,113,113); // colour for background
$style['rule']['textcolour'] = array(0,0,0); // colour for foreground
$style['rule']['drawcolour'] = array(0,0,0); // colour for line drawing
Easy peasy lemon squeezy (when you know how).
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
Re: PDF - horizontal line in title zone [message #5636 is a reply to message #5635] |
Thu, 16 June 2016 10:55 |
htManager
Messages: 433 Registered: May 2014
|
Senior Member |
|
|
I have found a solution. In the class file I insert a field in $row as field label. I examine the value of the field 'training_plan_detail_uebung_ablauf'. If it is null, the value for the (new) field 'training_plan_detail_uebung_ablauf_label' is null, too. So I can use the property 'ignore_if_empty' for the field label in the report.
Or is there a better/easier solution?
There is one problem left: The positions of the 'multiN' rows don't move to top if I have no output although I have inserted the property 'ignore_if_empty'. Do I have to do something more?
[Updated on: Thu, 16 June 2016 11:33] Report message to a moderator
|
|
|
|
|
|
|
Re: PDF - horizontal line in title zone [message #5644 is a reply to message #5643] |
Sat, 18 June 2016 06:09 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
If you look at the documentation you will see that the 'ignore_if_empty' options can be used in the 'title' element of a report structure file, but for detail reports it is specified in the style file. There is no mention of it being available in the 'multiN' element of a report.
The easiest way to accomplish what you want is to define each line with a different 'multiN' number, such as 'multi1' to 'multi8' instead of 8 lines for a 'multi1'. If you do not want a line to appear in the output then in your _cm_output_multi() method you return nothing. If you return a non-empty array then that 'multiN' line will be printed even if every element is blank.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: PDF - horizontal line in title zone [message #5647 is a reply to message #5646] |
Sun, 19 June 2016 05:02 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
Each line in your output has a label and a value, but at present you have everything as different lines in a 'multi1' element. What I am saying is that you should have your 2nd line as a 'multi2', your 3rd line as a 'multi3', et cetera. This also means that you would have to adjust your _cm_output_multi() method, but when you don't have anything to be printed on a particular line then you return nothing for that line.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: PDF - horizontal line in title zone [message #5663 is a reply to message #5653] |
Tue, 21 June 2016 04:41 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
If you look at the contents of _cm_output_multi() you will see a switch statement like the following:
$outarray = array();
switch ($name) {
case 'multi1':
// return a non-empty array to print an empty line
$outarray[] = array('dummy' => '');
break;
case 'multi2':
// return a non-empty array to print an empty line
$outarray[] = array('dummy' => '');
break;
case 'multi3':
// return a non-empty array to print an empty line
$outarray[] = array('dummy' => '');
break;
case 'multi4':
// return a non-empty array to print an empty line
$outarray[] = array('dummy' => '');
break;
.....
default:
// return a non-empty array to print an empty line
$outarray[] = array('dummy' => '');
break;
} // switch
return $outarray;
Each time this method is called is has a different 'multiN' value in $name, so within the relevant 'case' statement you require code to construct $outarray before it is returned. You are currently outputting both a label and a text field for each line, so in the situation where the text field is empty and you do not want the line printed at all then do nothing as $outarray is already empty. If you put ANYTHING at all in $outarray then the line WILL be printed even if there are no values to print.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: PDF - horizontal line in title zone [message #5670 is a reply to message #5666] |
Wed, 22 June 2016 05:25 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I have already shown you how to generate a horizontal line. The documentation already shows how you can out an image in a line. There is code in the EXAMPLE prototype whichs this.
If each line in the report has its own 'multiN' record, but if you do not want anything output (not even a blank line) then set $outarray to FALSE or an empty array. If there is anything in $outarray at all then a line will be printed, even if it is blank.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: PDF - horizontal line in title zone [message #5676 is a reply to message #5675] |
Sat, 25 June 2016 05:01 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
Your report structure file is wrong. Each line in the report is supposed to contain two fields. In the structure file that you sent me earlier you had the following:
$structure['multi1']['fields'][8][] = array('field' => 'xxx_label',
'width' => 15,
'border' => '',
'style' => 'label_tplan',
'ignore_if_empty' => 'y');
$structure['multi1']['fields'][8][] = array('field' => 'xxx',
'width' => 180,
'x' => 15,
'border' => '',
'ignore_if_empty' => 'y');
You should change it to the following:
$structure['multi8']['fields'][1][] = array('field' => 'xxx_label',
'width' => 15,
'border' => '',
'style' => 'label_tplan);
$structure['multi8']['fields'][1][] = array('field' => 'xxx',
'width' => 180,
'x' => 15,
'border' => '');
In your _cm_output_multi() method you should have code such as the following:
case 'multi8':
if (!empty($fieldarray['xxx') {
$outarray = array('xxx_label' => '...', 'xxx' => '...');
} else {
$outarray = array();
} // if
break;
The framework will output whatever values you give it. If you give it a row with empty values then it will print empty values. If you do not want the row printed at all then you must output an empty row and not a row containing empty values.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
|
|
|
|
Re: PDF - horizontal line in title zone [message #5710 is a reply to message #5708] |
Sun, 10 July 2016 10:30 |
htManager
Messages: 433 Registered: May 2014
|
Senior Member |
|
|
The line is 1 unit under the images. But the images seem to be still there. See attached picture.
This is the report.inc code:
$structure['multi1']['fields'][9][] = array('image' => '%%training_plan_detail_uebung_pfad_grafik_05',
'imagewidth' => 40,
'imageheight' => 40,
'border' => '',
'x' => 16,
'y_relative' => 1,
'ignore_if_empty' => 'y');
$structure['multi1']['fields'][][] = array('text' => '',
'style' => 'rule',
'y_relative' => 1,
'width' => '100%',
'newline' => 'y');
-
Attachment: grafik.png
(Size: 38.03KB, Downloaded 1055 times)
|
|
|
Re: PDF - horizontal line in title zone [message #5712 is a reply to message #5710] |
Mon, 11 July 2016 03:54 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
You are still making the mistake of defining all output elements in a single 'multi1' line. If you look at your output you should see that the images are on their own line, just as the horizontal rule is on its own line. Each line on your output should therefore be defined on its own 'multiN' element, such as 'multi1', 'multi2', 'multi3' etc. I have tried this in my test system, and when there are no images the line is not output at all instead of the being output with blank spaces where the images should be.
What you are trying to do is have a single row of data being split over several lines in the output, which makes it difficult when you want certain elements not to appear at all. You need to output a separate row for each line on the output, and when you want a line to be not printed at all you simply output an empty row for that line.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: PDF - horizontal line in title zone [message #5721 is a reply to message #5720] |
Wed, 13 July 2016 04:01 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I have told you what your mistake is - you have all the output in a single 'multi1' element which spans multiple lines, and sometimes one (or more) of those lines you want not to appear instead of being output as blank lines. You should have each line of output in its own 'multiN' element so that line 1 is 'multi1', line 2 is 'multi2', line 3 is 'multi3' et cetera. If you do not want a particular line to appear then output an empty row for that line.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: PDF - horizontal line in title zone [message #5729 is a reply to message #5722] |
Thu, 14 July 2016 04:47 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
If you have to output multiple lines in the same 'multi1' zone then you should read the documentation which says that each line should have its own line number. You can do this with code similar to the following:
$structure['multi1']['fields'][1][] = .... data for first line
$structure['multi1']['fields'][2][] = .... data for second line
$structure['multi1']['fields'][3][] = .... data for third line
Note the use of "['fields'][N][]" instead of "['fields'][][]".
I have tried this in my development environment, and it successfully drops a line where all fields are empty.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: PDF - horizontal line in title zone [message #5731 is a reply to message #5730] |
Fri, 15 July 2016 04:13 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
This works perfectly well in my development environment. I have adapted the "Invoice (PDF)" task in the EXAMPLE subsystem and produced the output shown in the attached image. I have 4 rows of data where the item id is 'Stuff', 'Other Stuff', 'Widgets' and 'Gadgets'. The data is shown in 3 lines: 1= standard data, 2= images and 3= a horizontal rule. In the attached image you will see that the data for 'Stuff' contains a label and 2 images, the data for 'Other Stuff' contains a label and 1 image. The data for the last 2 rows do not show any images at all, not even empty spaces where the images should be. I did this using the following code in the screen structure file:
// identify output for 1st additional zone
$structure['multi1']['fields'][1][] = array('field' => 'quantity', 'width' => 20, 'halign' => 'center', 'y_relative' => 1);
$structure['multi1']['fields'][1][] = array('field' => 'product_name', 'width' => 30);
$structure['multi1']['fields'][1][] = array('field' => 'product_desc', 'width' => 75);
$structure['multi1']['fields'][1][] = array('field' => 'product_price', 'width' => 25, 'halign' => 'right');
$structure['multi1']['fields'][1][] = array('field' => 'extended_price', 'width' => 25, 'halign' => 'right');
$structure['multi1']['fields'][1][] = array('field' => 'vat_percent', 'width' => 15, 'halign' => 'center');
// additional line to demonstrate 'ignore_if_empty' option
$structure['multi1']['fields'][2][] = array('field' => 'image_label',
'width' => '20',
'style' => 'noborder',
'y_relative' => 1,
'ignore_if_empty' => 'y');
$structure['multi1']['fields'][2][] = array('image' => '%%image_01',
'imagewidth' => 75,
'imageheight' => 95,
'style' => 'noborder',
'ignore_if_empty' => 'y');
$structure['multi1']['fields'][2][] = array('image' => '%%image_02',
'imagewidth' => 75,
'imageheight' => 95,
'style' => 'noborder',
'ignore_if_empty' => 'y');
// third line to put a horizontal rule across the page
$structure['multi1']['fields'][3][] = array('text' => '',
'width' => '100%',
'style' => 'rule',
'y_relative' => 1);
You need to compare this with your screen structure file so that you can spot the differences.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
Re: PDF - horizontal line in title zone [message #5737 is a reply to message #5734] |
Mon, 18 July 2016 04:45 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
After I inserted the code to allow the 'ignore_if_empty' option for images I tried testing it in a various combination of scenarios, and I hit a small problem when a cell containing an image was in the same line as one or more other cells containing text. After fixing that problem I thought that all was well, but when I reran your scenario I found that it did not work properly, so that was another problem that needed fixing. All my tests now work, so I think I've fixed everything, but Murphy's Law will probably prove me wrong.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
[Updated on: Mon, 18 July 2016 04:46] Report message to a moderator
|
|
|