tcpdf

Remove images when printing/saving PDF


I have a form PDF with an images in the background: $pdf->Image(...) User is supposed to fill out the form fields and then can save or print the result.

How can I hide the images at this point?

$alt = true doesn't help help me here.


Solution

  • From Example 24

    /*
     * setVisibility() allows to restrict the rendering of some
     * elements to screen or printout. This can be useful, for
     * instance, to put a background image or color that will
     * show on screen but won't print.
     */
    
    // set visibility only for screen
    $pdf->setVisibility('screen');
    
    ... objects to hide when printing
    
    // restore visibility
    $pdf->setVisibility('all');