pauln / tcpdi_parser

Parser for use with TCPDI, based on TCPDF_PARSER
GNU Lesser General Public License v3.0
27 stars 47 forks source link

TCPDI_PARSER ERROR: Invalid object reference: Array #12

Closed ghost closed 7 years ago

ghost commented 8 years ago

Hello,
I am trying to add watermarks to a an existing PDF by using this library:

$pdf = new TCPDI(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);  
if (file_exists(WatermarkPDF::$tmp_file)){  
    $pagecount = $pdf->setSourceFile($tmp_file);  
} else {  
    clear();  
    return FALSE;  
}

Unfortuantely I am getting an error:

Notice (8): Array to string conversion [APP/Vendor/WatermarkPDF/tcpdi_parser.php, line 951]  
TCPDI_PARSER ERROR: Invalid object reference: Array

The file is a valid PDF (v1.5) created by Latex so I am wondering whats wrong here..

pauln commented 8 years ago

Hi @MarcJose, Can you please supply a sample PDF which triggers this error? If you're not comfortable uploading it here as an attachment, you can email it directly to me at tcpdi-samples at next.gen.nz.

ghost commented 8 years ago

Hi, I attached a shortened file which produces the error message for me: Script.pdf Currently I am using pdftk to uncompress it first which somehow seem to solve the problem.

pauln commented 8 years ago

Hi @MarcJose, The PDF you attached seems to work fine for me. Can you please give me a bit more information about your environment (i.e. PHP version) and libraries (TCPDF and FPDF_TPL versions)?

ghost commented 8 years ago

Hi, I am using Ubuntu 14.04 LTS with PHP 5.5.9, Apache 2.4.7, FPDF_TPL 1.6.1 and TCPDF 6.2.12 currently and still getting the error with the code from above. I mean its kinda working when using pdftk first to uncompress it but I would prefer not using system-calls for this

pauln commented 8 years ago

Hi @MarcJose, Can you please try using the standalone version of FPDF_TPL (1.2.3) from https://www.setasign.com/products/fpdi/downloads/#package-10102 and see if it fixes the problem? I still haven't had a chance to work on supporting newer versions of FPDF_TPL, but I really ought to do so soon given the number of times people have tried using newer versions and encountered issues...

ghost commented 8 years ago

Sorry for the late reply, no it didnt work unfortunately but I found another library which seems to work...

axcl commented 6 years ago

Hi @MarcJose , Can you please let me know which library are you using. i am getting following issue when adding watermark with fpdi PHP Fatal error: Uncaught Exception: This document (.......) probably uses a compression technique which is not supported by the free parser shipped with FPDI.

ghost commented 6 years ago

Yes, I use a dirty-fix by uncompressing it first using pdftk, then render my watermark inside and finally compress it back again. This costs a few ms for each user but not in a way that it becomes too slow so I am okay with it.