A few weeks ago we released the newest version of the HTML to PDF SDK. In this post we’ll go into the new features that have been added in this version.
Our PHP SDK already supported a plethora of functions like page formats, margins, encryption, password protection etc. The newest features that now have been added consist of a set of watermarking options.
With this latest version of the SDK you can now:
- Add your own image as watermark to the PDF
- Add your own text in a font and size of your choice to the PDF
- Define the size and location of the watermark
- Define the angle of rotation of the watermark
- Define the opacity of the watermark – in case you choose fully opague, you will notice that the watermark looks like a stamp
The new watermarking functions that have been added to our PHP library are listed in the table below.
|SetWatermarkLocation||Input parameters: $x, $y|
Indicate where the watermark should start.
Note that the top left of a watermark image will start at this location, whilst this location will indicate the BOTTOM left of a text watermark
|SetWatermarkTransformation||Input parameters: $angle, $opacity, $scaling_x, $scaling_y|
Indicate the rotation in degrees, opacity from 0 to 1 (0 = fully transparant, 1 = fully opague) and scaling (horizontal and vertical) of the watermark
|SetWatermarkImage||Input parameter: $url|
Adds an image as watermark to all the pages of your PDF
|SetWatermarkText||Input parameters: $text, $fontname, $color, $fontsize|
Adds a text watermark to all the pages of your PDF
You control font name, color and size
The following example code shows how you can watermark your PDFs, by using the newest functions of the HTML to PDF SDK in PHP. If the above list of functions was not enough – this will surely get you going.
$pdf = new Htm2PdfApi ($userid, $apikey); // initialize
$pdf->SetWatermarkLocation(100,100); // put this at position 100,100
$pdf->SetWatermarkTransformation(45,1); // it's at an angle of 45 degrees
// and fully opague (so stamped)
$pdf->SetWatermarkText('SAMPLE','Tahoma','#000000',64); // Print SAMPLE in Tahoma
// use color black, size 64
$pdf->CreateFromURL('http://www.google.com'); // do the conversion
$pdf->Display(); // send it to the user as attachment
This hopefully shows you the power of the new watermarking functions in our HTML to PDF SDK. We feel this makes the SDK even more complete than it already was. If you want learn more about this service, then please view the full documentation we have compiled.
If you’re ready to give it a go – please sign up!