Closed GoogleCodeExporter closed 9 years ago
One of the problems with text generated using inline script is that it always
appears on top of any text generated as a result of rendering the HTML content.
Of course, that wouldn't be huge a problem if the page_text function support
opacity. The function itself will accept that value, but it won't pass it along
to the renderer.
The lack of opacity support may be a bug in the code, I'd have to look at how
the functionality interacts with the rendering engine. However, we're not
patching 0.5.1 anymore don't expect the functionality to be fixed.
That being said, it looks like what you really want is the following:
<script type="text/php">
$watermark = $pdf->open_object();
$w = $pdf->get_width();
$h = $pdf->get_height();
$pdf->text(110, $h - 240, "DELETED", Font_Metrics::get_font("verdana", "bold"),110, array(0.85, 0.85, 0.85), 0, -52);
$pdf->close_object();
$pdf->add_object($watermark, 'all');
</script>
See how I'm using the `text` method instead of the `page_text` method.
`page_text` places text using a global object, whereas `text` places the text
in the current object. You can create unattached objects that you then place in
the rendered document. So if you create your object on the first page using the
above code you can propagate that object to all pages of your document.
---
Another option would be to upgrade to 0.6.0. Using this version you can achieve
the same effect using CSS.
Original comment by eclecticgeek
on 21 May 2012 at 2:51
Thanks for your suggestions. I upgraded the version to 0.6.0. I copied your
code as above but things are not working so well.
As read in the related link :
http://stackoverflow.com/questions/4862417/dompdf-watermark-image-header-and-foo
ter-issues
I tried to change the opacity of the text in page_text() in cpdf_adapter.php
but it was not giving me the transparent effect, so for now i have inserted an
image that is running as a background.
<style>
body
{
background-image: url($imagepath);
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
</style>
Let me know if there is some alternative for achieving the same using watermark
rather than back ground image
Original comment by bthakk...@gmail.com
on 22 May 2012 at 8:51
In 0.6.0 I would create the watermark completely in CSS instead. See the
example here:
http://eclecticgeek.com/dompdf/debug.php?identifier=39d5d59fb77827b137c76c644a9f
2621
Original comment by eclecticgeek
on 31 May 2012 at 1:56
Hello Sir,
The link that you have given below is great and has solved my problem.
Thanks a lot![?][?]
Regards
Original comment by bthakk...@gmail.com
on 1 Jun 2012 at 7:12
how to add shadow/outline in text using
<script type="text/php">
$watermark = $pdf->open_object();
$w = $pdf->get_width();
$h = $pdf->get_height();
$pdf->text(110, $h - 240, "DELETED", Font_Metrics::get_font("verdana", "bold"),110, array(0.85, 0.85, 0.85), 0, -52);
$pdf->close_object();
$pdf->add_object($watermark, 'all');
</script>
Original comment by ankita.g...@gmail.com
on 1 Apr 2013 at 11:51
Original comment by eclecticgeek
on 30 May 2013 at 5:16
Original issue reported on code.google.com by
bthakk...@gmail.com
on 19 May 2012 at 9:42