Dompdf watermarks, images, headers and footers

I use dompdf as a plugin in codeigniter. it perfectly creates a PDF file. but some problems eat me for a few days.

  • I want to place the image as a title on every page of the generated pdf. I did this according to the manual given here . but no progress. I tried for images of all types (jpg, png, gif) in the same wheresript folder for pdf. this does not work. then I tried to set the path variable for the image and css as shown on http://code.google.com/p/dompdf/wiki/Usage. But I could not get a good example or tutorial for this. if any authority has ever used this, please help me.

  • I also want to add a watermark to each page. for this i use

    $pdf->page_text(110, $h - 240, "TRIAL", Font_Metrics::get_font("verdana", "bold"),110, array(0.92, 0.92, 0.92), 0, -58);.

This works great and creates a watermark. But the watermark hits the content. Is there any thing to change the opacity of the watermark. it does not change by changing the parameters in the array.

3. at the end of each page (except the last) I want to put the text " continued .. ". for this i use

$text = "Continued..";
  $width = Font_Metrics::get_text_width($text, $font, $size);
  $pdf->page_text($w - 16 - $width - 38, $y-15, $text, $font, $size, $color);

it puts text on every page (as it should). is there any way to place text on all pages except the last?

  • How to install a font that is not available in the dompdf lib file?
+3
source share
2 answers

1) What kind of code are you using? It looks like you have success with the built-in script, not the images. Therefore, there may be a problem with your code.

2) script. HTML, , HTML. , , , - . 0.6.0.

, , , , HTML ( , CSS).

3) , , . , , , . .

4) , load_font.php. ttf2afm (dompdf 0.5.1) ttf2ufm (dompdf 0.6.0). , , web . .

+2

, DOMPDF_ENABLE_PHP true dompdf_config.inc.php ~ 173 0.6.2 , , - , pdf.

/**
 * Enable inline PHP
 *
 * If this setting is set to true then DOMPDF will automatically evaluate
 * inline PHP contained within <script type="text/php"> ... </script> tags.
 *
 * Enabling this for documents you do not trust (e.g. arbitrary remote html
 * pages) is a security risk.  Set this option to false if you wish to process
 * untrusted documents.
 *
 * @var bool
 */
define("DOMPDF_ENABLE_PHP", true);
+1

Source: https://habr.com/ru/post/1789216/


All Articles