php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40557 object needed for as parameter but results in error
Submitted: 2007-02-20 12:26 UTC Modified: 2007-02-20 15:54 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ronnie at signet dot nl Assigned:
Status: Not a bug Package: PDF related
PHP Version: 5.2.1 OS: FreeBSD
Private report: No CVE-ID: None
 [2007-02-20 12:26 UTC] ronnie at signet dot nl
Description:
------------
I want to make an overlay on an existing PDF file, and according to what I find on your website and on the manual of PDFLib is that I need PDF_open_pdi (pdi ->pdf import).

the function description on the websites are :

int pdf_open_pdi(int resource, string filename, "",0)

however, when I make an empty PDF object with:
$p=new PDFlib, and I user $p as the first parameter in the call to the function pdf_open_pdi, I get the next errormessage :

PDFlib exception occured in hello sample : [0]: PDFlib::open_pdi() expects parameter 1 to be string, object given


Reproduce code:
---------------
I call to this function like this :

<?
...
$p = new PDFlib();
...
$filename = "testfile.pdf";
$p->open_pdi($pdf , $filename, ""); 
...
?>

In my opinion this should work... but it doesnt.

http://ronnie.signet.nl/pdftest.php

#I'll leave this file in place so you can see what it does

Expected result:
----------------
I expected the original pdf file to be opened and added as some sort of background, so I could take the default PDFlib functions to create some sort of overlay function.



Actual result:
--------------
However, if I create a blank pdf, and open another with open_pdi, instead of that I can do what's written in the PDFlib manual, I get an errormessage in return, that tells me that open_pdi's first parameter should be a string. But if this were a string, how should I be able to operate on it later as if it were a PDF (object) ?

I hope someone can figure out some answer for me, that I can make it work.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-20 12:27 UTC] ronnie at signet dot nl
of course the testfile.pdf  is an existing .pdf file, that's in the same directory as the .php file itself.
 [2007-02-20 12:49 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

http://ronnie.signet.nl/pdftest.php - 404 Not Found
 [2007-02-20 13:06 UTC] ronnie at signet dot nl
sorry, the correct link must by :

http://ronnie.signet.nl/testpdf.php
 [2007-02-20 14:27 UTC] tony2001@php.net
We still need a short but complete reproduce case.
 [2007-02-20 14:31 UTC] ronnie at signet dot nl
// this is the code that produces the error.

<?php
     // this is the file with most of the obsolete source stripped away
     $p = new PDFlib();
     
     /* open new pdf file; insert a file name to create the PDF on the disk */
     $p->begin_document("","")
     $p->set_info("Creator", "hello.php");
     $p->set_info("Author", "Rainer Schaaf");
     $p->set_info("Title", "Hello World (PHP)!");
     /* for testing purposes only */
     $filename = "ronnie.pdf";
     
     $p->open_pdi($filename, "",0);
     
     $p->setfont($font, 12.0);
     $p->set_text_pos(50,700);
     $p->show("Hello world!");
     $p->continue_text("  (says PHP)  ");
     $p->end_page_ext("");
     $p->end_document("");
     
     $buf = $p->get_buffer();
     $len = strlen($buf);
     
     header("Content-type: application/pdf");
     header("Content-length: $len");
     header("Content-Disposition: inline; filename=hello.pdf");
          
     print $buf;
?>
 [2007-02-20 15:43 UTC] ronnie at signet dot nl
Excuse me for not looking far enough. I just found that it wasn't realy a bug but a licencing problem. I found a class called acrostix.php that solves the problem for me.
 [2007-02-20 15:54 UTC] tony2001@php.net
.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Jan 23 07:01:25 2019 UTC