problem - generate dynamic PDF files on the server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yanlu06@gmail.com

    problem - generate dynamic PDF files on the server

    I tried to use HTML2FPDF to generate dynamic local files and save the
    generated files on the server. I don't know why it gives me the
    following error message:

    " Warning: fopen(gen_pdf/gen_pdf/yan.pdf) [function.fopen]: failed to
    open stream: No such file or directory in
    /export/home/.../pdfCov/fpdf.php on line 1698
    FPDF error: Unable to create output file: gen_pdf/yan.pdf "

    I cut and paste the following part of the code into a test.php file and
    run it. the test file can generate text file without any problem:

    $name="testfile .pdf";
    $handle = file_exists('ge n_pdf/'.$name);
    if (!$handle)
    {
    $f = fopen('gen_pdf/'.$name,'x+');
    }
    if(!$f) $this->Error('Unabl e to create output file: '.$name);
    fwrite ($f,"testtest") ;
    //fwrite($f,$this->buffer,strlen( $this->buffer)); //this line is in
    fpdf.php to generate pdf contents

    fclose($f)

    Anyone can help me out?

    Thanks!

  • kurt.milligan@gmail.com

    #2
    Re: problem - generate dynamic PDF files on the server

    Hi

    I don't know anything about the particular package you are using, but,
    looking at your error message and code snippet, I'd guess that the
    problem is that the gen_pdf/gen_pdf/ directory does not exist.
    (Your testfile just goes to the gen_pdf/ directory, but the package
    code appears to be trying to put the file in gen_pdf/gen_pdf/, and if
    that sub-directory doesn't exist, you will get that kind of fopen
    error.)

    HTH

    -Kurt

    Comment

    • yanlu06@gmail.com

      #3
      Re: problem - generate dynamic PDF files on the server

      Hi, Kurt,

      Thank you for your help.

      It was a dumb mistake while I was trying to test in different ways.

      I modified the code, but the same error message occurs:

      Warning: fopen(gen_pdf/yan.pdf) [function.fopen]: failed to open
      stream: No such file or directory in /export/home.../pdfCov/fpdf.php on
      line 1698
      FPDF error: Unable to create output file: yan.pdf

      Any idea what is wrong?

      Thanks!

      Comment

      Working...