1 package SL::ReportGenerator;
4 use List::Util qw(max);
10 # Cause locales.pl to parse these files:
11 # parse_html_template('report_generator/html_report')
12 # parse_html_template('report_generator/pdf_report')
19 $self->{myconfig} = shift;
20 $self->{form} = shift;
24 'std_column_visibility' => 0,
25 'output_format' => 'HTML',
26 'allow_pdf_export' => 1,
27 'allow_csv_export' => 1,
28 'html_template' => 'report_generator/html_report',
29 'pdf_template' => 'report_generator/pdf_report',
32 'orientation' => 'landscape',
33 'font_name' => 'Verdana',
37 'margin_bottom' => 1.5,
38 'margin_right' => 1.5,
48 'eol_style' => 'Unix',
54 'variable_list' => [],
57 $self->{data_present} = 0;
61 $self->set_options(@_) if (@_);
70 $self->{columns} = \%columns;
72 foreach my $column (values %{ $self->{columns} }) {
73 $column->{visible} = $self->{options}->{std_column_visibility} unless defined $column->{visible};
76 $self->set_column_order(sort keys %{ $self->{columns} });
79 sub set_column_order {
82 $self->{column_order} = [ grep { !$seen{$_}++ } @_, sort keys %{ $self->{columns} } ];
85 sub set_sort_indicator {
88 $self->{options}->{sort_indicator_column} = shift;
89 $self->{options}->{sort_indicator_direction} = shift;
97 while (my $arg = shift) {
100 if ('ARRAY' eq ref $arg) {
103 } elsif ('HASH' eq ref $arg) {
107 $self->{form}->error('Incorrect usage -- expecting hash or array ref');
110 my @columns_with_default_alignment = grep { defined $self->{columns}->{$_}->{align} } keys %{ $self->{columns} };
112 foreach my $row (@{ $row_set }) {
113 foreach my $column (@columns_with_default_alignment) {
114 $row->{$column} ||= { };
115 $row->{$column}->{align} = $self->{columns}->{$column}->{align} unless (defined $row->{$column}->{align});
118 foreach my $field (qw(data link)) {
119 map { $row->{$_}->{$field} = [ $row->{$_}->{$field} ] if (ref $row->{$_}->{$field} ne 'ARRAY') } keys %{ $row };
123 push @{ $self->{data} }, $row_set;
124 $last_row_set = $row_set;
126 $self->{data_present} = 1;
129 return $last_row_set;
135 push @{ $self->{data} }, { 'type' => 'separator' };
142 push @{ $self->{data} }, $data;
149 $self->{data_present} = 0;
156 while (my ($key, $value) = each %options) {
157 if ($key eq 'pdf_export') {
158 map { $self->{options}->{pdf_export}->{$_} = $value->{$_} } keys %{ $value };
160 $self->{options}->{$key} = $value;
165 sub set_options_from_form {
168 my $form = $self->{form};
169 my $myconfig = $self->{myconfig};
171 foreach my $key (qw(output_format)) {
172 my $full_key = "report_generator_${key}";
173 $self->{options}->{$key} = $form->{$full_key} if (defined $form->{$full_key});
176 foreach my $format (qw(pdf csv)) {
177 my $opts = $self->{options}->{"${format}_export"};
178 foreach my $key (keys %{ $opts }) {
179 my $full_key = "report_generator_${format}_options_${key}";
180 $opts->{$key} = $key =~ /^margin/ ? $form->parse_amount($myconfig, $form->{$full_key}) : $form->{$full_key};
185 sub set_export_options {
190 'variable_list' => [ @_ ],
194 sub get_attachment_basename {
196 my $filename = $self->{options}->{attachment_basename} || 'report';
197 $filename =~ s|.*\\||;
198 $filename =~ s|.*/||;
203 sub generate_with_headers {
205 my $format = lc $self->{options}->{output_format};
206 my $form = $self->{form};
208 if (!$self->{columns}) {
209 $form->error('Incorrect usage -- no columns specified');
212 if ($format eq 'html') {
213 my $title = $form->{title};
214 $form->{title} = $self->{title} if ($self->{title});
216 $form->{title} = $title;
218 print $self->generate_html_content();
220 } elsif ($format eq 'csv') {
221 my $filename = $self->get_attachment_basename();
222 print qq|content-type: text/csv\n|;
223 print qq|content-disposition: attachment; filename=${filename}.csv\n\n|;
224 $self->generate_csv_content();
226 } elsif ($format eq 'pdf') {
227 $self->generate_pdf_content();
230 $form->error('Incorrect usage -- unknown format (supported are HTML, CSV, PDF)');
234 sub get_visible_columns {
238 return grep { my $c = $self->{columns}->{$_}; $c && $c->{visible} && (($c->{visible} == 1) || ($c->{visible} =~ /\Q${format}\E/i)) } @{ $self->{column_order} };
245 $value = $main::locale->quote_special_chars('HTML', $value);
247 $value =~ s/\n/<br>/g;
252 sub prepare_html_content {
255 my ($column, $name, @column_headers);
257 my $opts = $self->{options};
258 my @visible_columns = $self->get_visible_columns('HTML');
260 foreach $name (@visible_columns) {
261 $column = $self->{columns}->{$name};
265 'link' => $column->{link},
266 'text' => $column->{text},
267 'show_sort_indicator' => $name eq $opts->{sort_indicator_column},
268 'sort_indicator_direction' => $opts->{sort_indicator_direction},
271 push @column_headers, $header;
274 my ($outer_idx, $inner_idx) = (0, 0);
278 foreach my $row_set (@{ $self->{data} }) {
279 if ('HASH' eq ref $row_set) {
280 if ($row_set->{type} eq 'separator') {
281 if (! scalar @rows) {
282 $next_border_top = 1;
284 $rows[-1]->{BORDER_BOTTOM} = 1;
292 'IS_COLSPAN_DATA' => $row_set->{type} eq 'colspan_data',
293 'NUM_COLUMNS' => scalar @visible_columns,
294 'BORDER_TOP' => $next_border_top,
295 'data' => $row_set->{data},
298 push @rows, $row_data;
300 $next_border_top = 0;
307 foreach my $row (@{ $row_set }) {
310 foreach my $col_name (@visible_columns) {
311 my $col = $row->{$col_name};
312 $col->{CELL_ROWS} = [ ];
313 foreach my $i (0 .. scalar(@{ $col->{data} }) - 1) {
314 push @{ $col->{CELL_ROWS} }, {
315 'data' => $self->html_format($col->{data}->[$i]),
316 'link' => $col->{link}->[$i],
320 # Force at least a to be displayed so that browsers
321 # will format the table cell (e.g. borders etc).
322 if (!scalar @{ $col->{CELL_ROWS} }) {
323 push @{ $col->{CELL_ROWS} }, { 'data' => ' ' };
324 } elsif ((1 == scalar @{ $col->{CELL_ROWS} }) && (!defined $col->{CELL_ROWS}->[0]->{data} || ($col->{CELL_ROWS}->[0]->{data} eq ''))) {
325 $col->{CELL_ROWS}->[0]->{data} = ' ';
330 'COLUMNS' => [ map { $row->{$_} } @visible_columns ],
331 'outer_idx' => $outer_idx,
332 'outer_idx_odd' => $outer_idx % 2,
333 'inner_idx' => $inner_idx,
334 'BORDER_TOP' => $next_border_top,
337 push @rows, $row_data;
339 $next_border_top = 0;
343 my @export_variables = $self->{form}->flatten_variables(@{ $self->{export}->{variable_list} });
345 my $allow_pdf_export = $opts->{allow_pdf_export} && (-x $main::html2ps_bin) && (-x $main::ghostscript_bin);
347 eval { require PDF::API2; require PDF::Table; };
348 $allow_pdf_export |= 1 if (! $@);
351 'TITLE' => $opts->{title},
352 'TOP_INFO_TEXT' => $self->html_format($opts->{top_info_text}),
353 'RAW_TOP_INFO_TEXT' => $opts->{raw_top_info_text},
354 'BOTTOM_INFO_TEXT' => $self->html_format($opts->{bottom_info_text}),
355 'RAW_BOTTOM_INFO_TEXT' => $opts->{raw_bottom_info_text},
356 'ALLOW_PDF_EXPORT' => $allow_pdf_export,
357 'ALLOW_CSV_EXPORT' => $opts->{allow_csv_export},
358 'SHOW_EXPORT_BUTTONS' => ($allow_pdf_export || $opts->{allow_csv_export}) && $self->{data_present},
359 'COLUMN_HEADERS' => \@column_headers,
360 'NUM_COLUMNS' => scalar @column_headers,
362 'EXPORT_VARIABLES' => \@export_variables,
363 'EXPORT_VARIABLE_LIST' => join(' ', @{ $self->{export}->{variable_list} }),
364 'EXPORT_NEXTSUB' => $self->{export}->{nextsub},
365 'DATA_PRESENT' => $self->{data_present},
371 sub generate_html_content {
373 my $variables = $self->prepare_html_content();
375 return $self->{form}->parse_html_template($self->{options}->{html_template}, $variables);
381 return $_[0] * 72 / 2.54;
384 sub render_pdf_with_pdf_api2 {
386 my $variables = $self->prepare_html_content();
387 my $form = $self->{form};
388 my $myconfig = $self->{myconfig};
390 my $opts = $self->{options};
391 my $pdfopts = $opts->{pdf_export};
393 my (@data, @column_props, @cell_props);
396 my $cell_props_row = [];
397 my @visible_columns = $self->get_visible_columns('HTML');
399 foreach $name (@visible_columns) {
400 $column = $self->{columns}->{$name};
402 push @{ $data_row }, $column->{text};
403 push @{ $cell_props_row }, {};
404 push @column_props, { 'justify' => $column->{align} eq 'right' ? 'right' : 'left' };
407 push @data, $data_row;
408 push @cell_props, $cell_props_row;
410 my $num_columns = scalar @column_props;
412 foreach my $row_set (@{ $self->{data} }) {
413 if ('HASH' eq ref $row_set) {
414 if ($row_set->{type} eq 'colspan_data') {
415 push @data, [ $row_set->{data} ];
417 $cell_props_row = [];
418 push @cell_props, $cell_props_row;
420 foreach (0 .. $num_columns - 1) {
421 push @{ $cell_props_row }, { 'background_color' => '#666666',
422 'font_color' => '#ffffff',
423 'colspan' => $_ == 0 ? -1 : undef, };
429 foreach my $row (@{ $row_set }) {
431 push @data, $data_row;
434 foreach my $col_name (@visible_columns) {
435 my $col = $row->{$col_name};
436 push @{ $data_row }, join("\n", @{ $col->{data} });
438 $column_props[$col_idx]->{justify} = 'right' if ($col->{align} eq 'right');
443 $cell_props_row = [];
444 push @cell_props, $cell_props_row;
446 foreach (0 .. $num_columns - 1) {
447 push @{ $cell_props_row }, { };
452 foreach my $i (0 .. scalar(@data) - 1) {
453 my $aref = $data[$i];
454 my $num_columns_here = scalar @{ $aref };
456 if ($num_columns_here < $num_columns) {
457 push @{ $aref }, ('') x ($num_columns - $num_columns_here);
458 } elsif ($num_columns_here > $num_columns) {
459 splice @{ $aref }, $num_columns;
464 'a3' => [ 842, 1190 ],
465 'a4' => [ 595, 842 ],
466 'a5' => [ 420, 595 ],
467 'letter' => [ 612, 792 ],
468 'legal' => [ 612, 1008 ],
471 my %supported_fonts = map { $_ => 1 } qw(courier georgia helvetica times verdana);
473 my $paper_size = defined $pdfopts->{paper_size} && defined $papersizes->{lc $pdfopts->{paper_size}} ? lc $pdfopts->{paper_size} : 'a4';
474 my ($paper_width, $paper_height);
476 if (lc $pdfopts->{orientation} eq 'landscape') {
477 ($paper_width, $paper_height) = @{$papersizes->{$paper_size}}[1, 0];
479 ($paper_width, $paper_height) = @{$papersizes->{$paper_size}}[0, 1];
482 my $margin_top = _cm2bp($pdfopts->{margin_top} || 1.5);
483 my $margin_bottom = _cm2bp($pdfopts->{margin_bottom} || 1.5);
484 my $margin_left = _cm2bp($pdfopts->{margin_left} || 1.5);
485 my $margin_right = _cm2bp($pdfopts->{margin_right} || 1.5);
487 my $table = PDF::Table->new();
488 my $pdf = PDF::API2->new();
489 my $page = $pdf->page();
491 $pdf->mediabox($paper_width, $paper_height);
493 my $font = $pdf->corefont(defined $pdfopts->{font_name} && $supported_fonts{lc $pdfopts->{font_name}} ? ucfirst $pdfopts->{font_name} : 'Verdana',
494 '-encoding' => $main::dbcharset || 'ISO-8859-15');
495 my $font_size = $pdfopts->{font_size} || 7;
496 my $title_font_size = $font_size + 1;
498 my $font_height = $font_size + 2 * $padding;
499 my $title_font_height = $font_size + 2 * $padding;
501 my $header_height = 2 * $title_font_height if ($opts->{title});
502 my $footer_height = 2 * $font_height if ($pdfopts->{number});
504 my $top_text_height = 0;
506 if ($self->{options}->{top_info_text}) {
507 my $top_text = $self->{options}->{top_info_text};
508 $top_text =~ s/\r//g;
509 $top_text =~ s/\n+$//;
511 my @lines = split m/\n/, $top_text;
512 $top_text_height = $font_height * scalar @lines;
514 foreach my $line_no (0 .. scalar(@lines) - 1) {
515 my $y_pos = $paper_height - $margin_top - $header_height - $line_no * $font_height;
516 my $text_obj = $page->text();
518 $text_obj->font($font, $font_size);
519 $text_obj->translate($margin_left, $y_pos);
520 $text_obj->text($lines[$line_no]);
528 'w' => $paper_width - $margin_left - $margin_right,
529 'start_y' => $paper_height - $margin_top - $header_height - $top_text_height,
530 'next_y' => $paper_height - $margin_top - $header_height,
531 'start_h' => $paper_height - $margin_top - $margin_bottom - $header_height - $footer_height - $top_text_height,
532 'next_h' => $paper_height - $margin_top - $margin_bottom - $header_height - $footer_height,
534 'background_color_odd' => '#ffffff',
535 'background_color_even' => '#eeeeee',
537 'font_size' => $font_size,
538 'font_color' => '#000000',
540 'bg_color' => '#ffffff',
542 'font_color' => '#000000',
544 'column_props' => \@column_props,
545 'cell_props' => \@cell_props,
548 foreach my $page_num (1..$pdf->pages()) {
549 my $curpage = $pdf->openpage($page_num);
551 if ($pdfopts->{number}) {
552 my $label = $main::locale->text("Page #1/#2", $page_num, $pdf->pages());
553 my $text_obj = $curpage->text();
555 $text_obj->font($font, $font_size);
556 $text_obj->translate(($paper_width - $margin_left - $margin_right) / 2 + $margin_left - $text_obj->advancewidth($label) / 2, $margin_bottom);
557 $text_obj->text($label);
560 if ($opts->{title}) {
561 my $text_obj = $curpage->text();
563 $text_obj->font($font, $title_font_size);
564 $text_obj->translate(($paper_width - $margin_left - $margin_right) / 2 + $margin_left - $text_obj->advancewidth($opts->{title}) / 2,
565 $paper_height - $margin_top);
566 $text_obj->text($opts->{title}, '-underline' => 1);
570 my $content = $pdf->stringify();
573 if ($pdfopts->{print} && $pdfopts->{printer_id}) {
574 $form->{printer_id} = $pdfopts->{printer_id};
575 $form->get_printer_code($myconfig);
576 $printer_command = $form->{printer_command};
579 if ($printer_command) {
580 $self->_print_content('printer_command' => $printer_command,
581 'content' => $content,
582 'copies' => $pdfopts->{copies});
583 $form->{report_generator_printed} = 1;
586 my $filename = $self->get_attachment_basename();
588 print qq|content-type: application/pdf\n|;
589 print qq|content-disposition: attachment; filename=${filename}.pdf\n\n|;
595 sub verify_paper_size {
597 my $requested_paper_size = lc shift;
598 my $default_paper_size = shift;
600 my %allowed_paper_sizes = map { $_ => 1 } qw(a3 a4 a5 letter legal);
602 return $allowed_paper_sizes{$requested_paper_size} ? $requested_paper_size : $default_paper_size;
605 sub render_pdf_with_html2ps {
607 my $variables = $self->prepare_html_content();
608 my $form = $self->{form};
609 my $myconfig = $self->{myconfig};
610 my $opt = $self->{options}->{pdf_export};
612 my $opt_number = $opt->{number} ? 'number : 1' : '';
613 my $opt_landscape = $opt->{orientation} eq 'landscape' ? 'landscape : 1' : '';
615 my $opt_paper_size = $self->verify_paper_size($opt->{paper_size}, 'a4');
617 my $html2ps_config = <<"END"
627 type: ${opt_paper_size};
633 margin-top: $opt->{margin_top}cm;
634 margin-left: $opt->{margin_left}cm;
635 margin-bottom: $opt->{margin_bottom}cm;
636 margin-right: $opt->{margin_right}cm;
640 font-family: Helvetica;
641 font-size: $opt->{font_size}pt;
648 if ($opt->{print} && $opt->{printer_id}) {
649 $form->{printer_id} = $opt->{printer_id};
650 $form->get_printer_code($myconfig);
651 $printer_command = $form->{printer_command};
654 my $cfg_file_name = Common::tmpname() . '-html2ps-config';
655 my $cfg_file = IO::File->new($cfg_file_name, 'w') || $form->error($locale->text('Could not write the html2ps config file.'));
657 $cfg_file->print($html2ps_config);
660 my $html_file_name = Common::tmpname() . '.html';
661 my $html_file = IO::File->new($html_file_name, 'w');
664 unlink $cfg_file_name;
665 $form->error($locale->text('Could not write the temporary HTML file.'));
668 $html_file->print($form->parse_html_template($self->{options}->{pdf_template}, $variables));
672 "\"${main::html2ps_bin}\" -f \"${cfg_file_name}\" \"${html_file_name}\" | " .
673 "\"${main::ghostscript_bin}\" -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=${opt_paper_size} -sOutputFile=- -c .setpdfwrite -";
675 my $gs = IO::File->new("${cmdline} |");
679 if (!$printer_command) {
680 my $filename = $self->get_attachment_basename();
681 print qq|content-type: application/pdf\n|;
682 print qq|content-disposition: attachment; filename=${filename}.pdf\n\n|;
684 while (my $line = <$gs>) {
689 while (my $line = <$gs>) {
695 unlink $cfg_file_name, $html_file_name;
697 if ($printer_command && $content) {
698 $self->_print_content('printer_command' => $printer_command,
699 'content' => $content,
700 'copies' => $opt->{copies});
701 $form->{report_generator_printed} = 1;
705 unlink $cfg_file_name, $html_file_name;
706 $form->error($locale->text('Could not spawn html2ps or GhostScript.'));
714 foreach my $i (1 .. max $params{copies}, 1) {
715 my $printer = IO::File->new("| $params{printer_command}");
716 $main::form->error($main::locale->text('Could not spawn the printer command.')) if (!$printer);
717 $printer->print($params{content});
722 sub generate_pdf_content {
725 eval { require PDF::API2; require PDF::Table; };
728 return $self->render_pdf_with_html2ps(@_);
730 return $self->render_pdf_with_pdf_api2(@_);
734 sub unescape_string {
737 my $iconv = $main::locale->{iconv};
739 $text = $main::locale->unquote_special_chars('HTML', $text);
740 $text = $main::locale->{iconv}->convert($text) if ($main::locale->{iconv});
745 sub generate_csv_content {
748 my %valid_sep_chars = (';' => ';', ',' => ',', ':' => ':', 'TAB' => "\t");
749 my %valid_escape_chars = ('"' => 1, "'" => 1);
750 my %valid_quote_chars = ('"' => 1, "'" => 1);
752 my $opts = $self->{options}->{csv_export};
753 my $eol = $opts->{eol_style} eq 'DOS' ? "\r\n" : "\n";
754 my $sep_char = $valid_sep_chars{$opts->{sep_char}} ? $valid_sep_chars{$opts->{sep_char}} : ';';
755 my $escape_char = $valid_escape_chars{$opts->{escape_char}} ? $opts->{escape_char} : '"';
756 my $quote_char = $valid_quote_chars{$opts->{quote_char}} ? $opts->{quote_char} : '"';
758 $escape_char = $quote_char if ($opts->{escape_char} eq 'QUOTE_CHAR');
760 my $csv = Text::CSV_XS->new({ 'binary' => 1,
761 'sep_char' => $sep_char,
762 'escape_char' => $escape_char,
763 'quote_char' => $quote_char,
766 my $stdout = wraphandle(\*STDOUT);
767 my @visible_columns = $self->get_visible_columns('CSV');
769 if ($opts->{headers}) {
770 $csv->print($stdout, [ map { $self->unescape_string($self->{columns}->{$_}->{text}) } @visible_columns ]);
773 foreach my $row_set (@{ $self->{data} }) {
774 next if ('ARRAY' ne ref $row_set);
775 foreach my $row (@{ $row_set }) {
777 foreach my $col (@visible_columns) {
778 push @data, join($eol, map { s/\r?\n/$eol/g; $_ } @{ $row->{$col}->{data} });
780 $csv->print($stdout, \@data);
791 SL::ReportGenerator.pm: the Lx-Office way of getting data in shape
795 my $report = SL::ReportGenerator->new(\%myconfig, $form);
796 $report->set_options(%options); # optional
797 $report->set_columns(%column_defs);
798 $report->set_sort_indicator($column, $direction); # optional
799 $report->add_data($row1, $row2, @more_rows);
800 $report->generate_with_headers();
802 This creates a report object, sets a few columns, adds some data and generates a standard report.
803 Sorting of columns will be alphabetic, and options will be set to their defaults.
804 The report will be printed including table headers, html headers and http headers.
808 Imagine the following scenario:
809 There's a simple form, which loads some data from the database, and needs to print it out. You write a template for it.
810 Then there may be more than one line. You add a loop in the template.
811 Then there are some options made by the user, such as hidden columns. You add more to the template.
812 Then it lacks usability. You want it to be able to sort the data. You add code for that.
813 Then there are too many results, you need pagination, you want to print or export that data..... and so on.
815 The ReportGenerator class was designed because this exact scenario happened about half a dozen times in Lx-Office.
816 It's purpose is to manage all those formating, culling, sorting, and templating.
817 Which makes it almost as complicated to use as doing the work for yourself.
823 =item new \%myconfig,$form,%options
825 Creates a new ReportGenerator object, sets all given options, and returns it.
827 =item set_columns %columns
829 Sets the columns available to this report.
831 =item set_column_order @columns
833 Sets the order of columns. Any columns not present here are appended in alphabetic order.
835 =item set_sort_indicator $column,$direction
837 Sets sorting ot the table by specifying a column and a direction, where the direction will be evaluated to ascending if true.
838 Note that this is only for displaying. The data has to be presented already sorted.
840 =item add_data \@data
842 =item add_data \%data
844 Adds data to the report. A given hash_ref is interpreted as a single line of data, every array_ref as a collection of lines.
845 Every line will be expected to be in a kay => value format. Note that the rows have to be already sorted.
846 ReportGenerator does only colum sorting on its own, and provides links to sorting and visual cue as to which column was sorted by.
850 Adds a separator line to the report.
852 =item add_control \%data
854 Adds a control element to the data. Control elements are an experimental feature to add functionality to a report the regular data cannot.
855 Every control element needs to set IS_CONTROL_DATA, in order to be recongnized by the template.
856 Currently the only control element is a colspan element, which can be used as a mini header further down the report.
860 Deletes all data filled into the report, but keeps options set.
862 =item set_options %options
864 Sets options. For an incomplete list of options, see section configuration.
866 =item set_options_from_form
868 Tries to import options from the $form object given at creation
870 =item set_export_options $next_sub,@variable_list
872 Sets next_sub and additional variables needed for export.
874 =item get_attachment_basename
876 Returns the set attachment_basename option, or 'report' if nothing was set. See configuration for the option.
878 =item generate_with_headers
880 Parses the report, adds headers and prints it out. Headers depend on the option 'output_format',
881 for example 'HTML' will add proper table headers, html headers and http headers. See configuration for this option.
883 =item get_visible_columns $format
885 Returns a list of columns that will be visible in the report after considering all options or match the given format.
887 =item html_format $value
889 Escapes HTML characters in $value and substitutes newlines with '<br>'. Returns the escaped $value.
891 =item prepare_html_content $column,$name,@column_headers
893 Parses the data, and sets internal data needed for certain output format. Must be called once before the template is invoked.
894 Should not be called extrenally, since all render and generate functions invoke it anyway.
896 =item generate_html_content
898 The html generation function. Is invoked by generate_with_headers.
900 =item generate_pdf_content
902 The PDF generation function. It is invoked by generate_with_headers, tests whether or not the Perl module PDF::API2 is installed and calls render_pdf_with_pdf_api2 if it is and render_pdf_with_html2ps otherwise.
904 =item generate_csv_content
906 The CSV generation function. Uses XS_CSV to parse the information into csv.
908 =item render_pdf_with_pdf_api2
910 PDF render function using the Perl module PDF::API2.
912 =item render_pdf_with_html2ps
914 PDF render function using the external application html2ps.
920 These are known options and their defaults. Options for pdf export and csv export need to be set as a hashref inside the export option.
922 =head2 General Options
926 =item std_column_visibility
928 Standard column visibility. Used if no visibility is set. Use this to save the trouble of enabling every column. Default is no.
932 Output format. Used by generate_with_headers to determine the format. Supported options are HTML, CSV, and PDF. Default is HTML.
934 =item allow_pdf_export
936 Used to determine if a button for PDF export should be displayed. Default is yes. The PDF button is hidden if neither the Perl module PDF::API2 nor the external applications html2ps and Ghostscript are available regardless of this parameter's value.
938 =item allow_csv_export
940 Used to determine if a button for CSV export should be displayed. Default is yes.
944 The template to be used for HTML reports. Default is 'report_generator/html_report'.
948 The template to be used for PDF reports. Default is 'report_generator/pdf_report'.
958 Paper size. Default is a4. Supported paper sizes are a3, a4, a5, letter and legal.
960 =item orientation (landscape)
962 Landscape or portrait. Default is landscape.
966 Default is Verdana. Supported font names are Courier, Georgia, Helvetica, Times and Verdana. This option only affects the rendering with PDF::API2.
970 Default is 7. This option only affects the rendering with PDF::API2.
980 The paper margins in cm. They all default to 1.5.
984 Set to a true value if the pages should be numbered. Default is 1.
988 If set then the resulting PDF will be output to a printer. If not it will be downloaded by the user. Default is no.
1006 Character to enclose entries. Default is double quote (").
1010 Character to separate entries. Default is semicolon (;).
1014 Character to escape the quote_char. Default is double quote (").
1018 End of line style. Default is Unix.
1022 Include headers? Default is yes.
1030 =head1 MODULE AUTHORS
1032 Moritz Bunkus E<lt>mbunkus@linet-services.deE<gt>
1034 L<http://linet-services.de>