Introduction
Apitron PDF Kit is an outstanding
library for all kinds of tasks related to PDF, it offers
well-designed and balanced API that follows the specification as much
as possible at the same time making your life easier by automating
many routine operations.
We decided to take it one step further
and introduced Apitron PDF Kit open source extensions library which
would automate most frequent pdf manipulation activities, and started
with adding digital signatures and watermarks.
The project pursues
two main goals:
1. Make PDF processing
more intuitive and straightforward
2. Show how the base
Apitron PDF Kit API works using real-life examples
The source code for the library can be found in
our github repo by the following link.
We will probably wrap it as a nuget package later, but for now you
can just checkout the code and compile it yourself.
Code samples
Signing is very simple and consist of a one line call
of the method Sign, you provide the certicate, password, signature
image and its boundaries and a few optional params if needed.
using (Stream inputStream = File.Open("../../data/letter_unsigned.pdf", FileMode.Open))
{
using (FixedDocument doc = new FixedDocument(inputStream))
{
doc.Sign("../../data/johndoe.pfx", "password",
"../../data/signatureImage.png",
new Boundary(100, 140, 190, 180), outputFileName);
}
}
And the
result:
Pic.
1 Signed PDF Document
|
Same applies to
stamping a document with a transparent watermark, just add a one-line
call and voilĂ :
{
using (FixedDocument doc = new FixedDocument(inputStream))
{
doc.Watermark("../../data/watermarkTransparent.png", outputFileName);
}
}
The result is below:
Pic.
2 Stamped PDF document
|
Summary
If you need to incorporate the basic PDF
processing functionality into your applications, then the open-source
Apitron PDF Kit extensions library we’ve published a few weeks ago
could be the right choice. It saves time keeping things simple, and
you can always fallback to the main API if you need something going
beyond its capabilities.
No comments:
Post a Comment