Custom PDF export

juergen_mueller

DaDaBIK Guru
Hi Eugenio

I want to add a custom pdf export to a details view.

I followed your documentation on how to set up a custom PDF export feature:

- I disabled $export_to_pdf_feature and enabled $parse_pdf_php_template_even_if_export_pdf_disable
- I created a layout hook (and a custom button as an alternative)
- the hook looks like '$hooks['MYTABLE']['details_form_header']['after'] = 'dadabik_pdf';
- the function looks like 'function dadabik_pdf() {echo 'PDF '; }
- MYTEMPLATE without .html ending

The hook appears but the link just opens the grid view of the concerned table...

What am I doing wrong?

Best,
Juergen
 

eugenio

Administrator
Staff member
Hello Juergen,
I think you missed to enable pdf export for that specific template, basically in MYTEMPLATE.php you should add

$export_to_pdf_feature = 1

Maybe it was not clear in the documentation.

Best,
 

juergen_mueller

DaDaBIK Guru
Just one thing: is there a possibility to delete or deactivate this message 'The export limit has been set to 1 records by the administrator.' ?
 

eugenio

Administrator
Staff member
Hello,
the message should be related to the parameter $pdf_max_number_records, which by default is NOT set. Are you getting that message even if the $pdf_max_number_records is not set?

Best,
 

juergen_mueller

DaDaBIK Guru
Hi Eugenio

No, but of course then all records will be included in the PDF - I just need one for the details view.

This is my config (main config)

$export_to_pdf_feature = 0;

//$pdf_creation_time_limt = 30;

$pdf_max_number_records = 0;

$add_pdf_page_for_each_record = 1;

$pdf_page_orientation = 'P';

$parse_pdf_php_template_even_if_export_pdf_disable = 1;

I use a custom PDF template & php file with the following config:

$export_to_pdf_feature = 1;
$pdf_max_number_records =1;

With this setup I get the message ''The export limit...'

Best

Juergen
 

eugenio

Administrator
Staff member
Hello,
if you are in the details of a record, you should get a pdf exactly for that record and not for all the records, regardless of $pdf_max_number_records. What happens exactly if you don't set $pdf_max_number_records (comment both the lines)?

Best,
 

juergen_mueller

DaDaBIK Guru
If I uncomment $pdf_max_number_records or set it '0' I still get all the records in the table, even from the details view...

Maybe it's the function called by the button?

function dadabik_pdf()
{
header('Location: index.php?tablename=TABLENAME&function=search&export_to_pdf=1&pdf_template=TEMPLATE');
}

Best,
 

eugenio

Administrator
Staff member
Oh yes, definitely, that URL is for producing the PDF for all the records, you should use

index.php?tablename=TABLENAME&function=details&export_to_pdf=1&pdf_template=TEMPLATE&where_field=YOURUNIQUEFIELD&where_value=YOURUNIQUEFIELDVALUE

Bestm
 

juergen_mueller

DaDaBIK Guru
Hi, Eugenio

thanks a lot, that solved the issue.

This thread helped as well https://dadabik.com/forum/read.php?1,20784,21026#msg-21026

Best

Juergen
 
Top