Name

Introduction to the PDF importer

Description

The importer is intended to allow a pre-existing PDF file to be imported into phppdflib so that it can be altered, or additional information added. This is a feature that has been requested by many people.

Examples

  • See example-import.php in the examples directory.
  • The following should demonstrate some of the possibilities:
  • $pdf = new PDFFile;
    $pdf->enable('import');
    $pages[] = $pdf->new_page(); // Create a page with default values
    $pdf->import->append('SomeExistingPDFFile.pdf');
    $pages = $pdf->import->get_pages($pages);
    $pages[] = $pdf->new_page(); // Add a page after the appended PDF
    foreach ($pages as $page) {
        $pdf->draw_text(0, 0, 'This text is on every page', $page);
    }
    

    See Also

    History

    The first incarnation of the importer was added in 2.7

    The first functional version of the importer appeared in version 2.9, thanks to development sponsorship.

    Bugs

    The importer is still very new. If it chokes on a PDF file that you'd like to import (that you are sure is a valid PDF, i.e. it actually opens in a PDF viewer) please file a bug report that includes the PDF file itself.

    The importer can't import PDFs that are encrypted, or where content streams are compressd with any algorithm except /FlateDecode. (This does not include images, the importer should be able to import GIFs without trouble.)

    At this time, the importer ignores embedded fonts, converting any font that it doesn't understand to Helvetica. This is likely to cause unexpected layout problems (actually, they should only be unexpected if you haven't read this page ... having read it, you should expect such problems ;)