Introduction
In our previous post we announced the release of the open source extensions library for Apitron PDF Kit. We continue making code contributions to this project, so recently a pack of changes related to text watermark support was added and now you can promptly add watermarks using text strings in addition to images.
For those thinking about keeping doc’s size as small as possible, textual watermarks seem to have a clear advantage over images as they usually need less bytes to store. The source code for the library can be found in our github repo by the following link. See the demo of new functionality and samples below.
Code samples
Adding text watermark is super easy:
using (Stream inputStream = File.Open("../../data/letter_unsigned.pdf", FileMode.Open))
{
string watermarkText = "TOP secret -for INTERNAL use - TOP secret - for
INTERNAL use - TOP secret - for INTERNAL use - TOP secret";
using (FixedDocument doc = new FixedDocument(inputStream))
{
doc.WatermarkText(watermarkText, outputFileName);
}
}
using (FixedDocument doc = new FixedDocument(inputStream))
{
doc.WatermarkText(watermarkText, outputFileName);
}
}
The result is below:
Pic.1
Text watermark
|
Summary
By releasing the Apitron PDF Kit Extensions we wanted to show you how to use the base API and at the same time make things simpler by implementing some tricky things in very a customizable way. Just get the base code and adapt it to your needs or add you own extensions. Don’t forget to share nice snippets with others.
No comments:
Post a Comment