pdf links

PDF Rendering
Convert PDF to Image (.NET)
Convert PDF to image on Android (Xamarin)
Convert PDF to image on iOS (Xamarin)
Convert PDF to image in Windows Store apps (.NET)
Convert PDF to image in Windows Phone apps (.NET)
PDF to image in Universal Windows Store apps (.NET)
Free PDF Viewer control for Windows Forms (.NET)
How to integrate PDF Viewer control in WPF app (.NET)
Creating WPF PDF Viewer supporting bookmarks (.NET)
Cross-platform PDF Viewer using GTK# (MONO)
Silverlight PDF viewer control (Silverlight 5)
Multithreaded PDF rendering (.NET)
Convert pdf to image in Silverlight app (C# sample)
How to set fallback fonts for PDF rendering (C#)
Avoiding the out-of-memory exception on rendering (C#)
PDF viewer single page application (WebAPI, AngularJS)
PDF viewer control for Windows 10 universal applications
Use custom ICC profile for CMYK to RGB conversion
PDF layers - separate images, text, annotations, graphics

PDF Forms Creation PDF Security
Conversion to PDF/A
Other topics
PDF Document Manipulation
PDF Content Generation
Fixed and Flow layout document API (.NET)
Creation of grids and tables in PDF (C# sample)
How to create interactive documents using Actions (C# sample)
Text flow effects in PDF (C# sample)
How to generate ordered and bulleted lists in PDF (C# sample)
Convert HTML to PDF using flow layout API (C# sample)
How to use custom fonts for PDF generation (.NET)
Create document with differently sized pages (C#)
Create PDF documents using MONO (C#/MONO/Windows/OSX)
How to use background images for content elements (C#/PDF Kit/FlowLayout)
Add transparent images to PDF document (C#)
Draw round rect borders in PDF documents(C#)
ICC color profiles and and ICC based colors in PDF (C#)
How to use bidirectional and right to left text in PDF (C#)
Create PDF documents from XML templates (C# sample)
How to resize PDF pages and use custom stamps (C#)
Add header and footer to PDF page (.NET sample)
How to use clipping mask for drawing on PDF page
Fill graphics path with gradient brushes in PDF (Shadings)
Apitron PDF Kit and Rasterizer engine settings
Add layers to PDF page (optional content, C# sample)
How to create free text annotation with custom appearance

PDF Content Extraction
PDF Navigation

PDF to TIFF conversion
Contact us if you have a PDF related question and we'll cover it in our blog.

2017-10-23

Web API for PDF processing

Introduction


New development challenges continuously call for yet another things to be done to circumvent the tricky limitations all big name platform providers impose on us for whatever reasons. Nevertheless we, at Apitron, believe that it just makes our software better and if one could use a rewording – cuts it like a diamond for it to become an even better all-around tool for our customers.

We already went a long way to make our tools cross-platform with .NET, MONO and Xamarin, so now they cover many usage scenarios and provide a solid toolset for creating full-cycle PDF processing apps. But we have even more to offer, a web API for PDF processing with the focus on signing and watermarking of documents. It’s designed to be hosted in-house but we have a demo installation publicly available as well.


Demo


Like it has been said before, the API can be hosted anywhere including your own server if you need. It supports signing and watermarking of PDF documents and we have set up a test installation for you to try it out. The slides below demonstrate the user interface of a test client web app that makes use of the aforementioned web api and is available for download from our github repo. As the first step after downloading, you’d have to configure the app to use the right web api installation URL by editing the “ServiceUrl” in its web.config. We used our demo url here.

Pic. 1 Configuring client app
Pic. 1 Configuring client app

After that we can run the app in browser and proceed by selecting the file and desired action, see below:

Pic. 2 Selecting source file and desired action
Pic. 2 Selecting source file and desired action

Source document used here is a dummy letter crafted for illustrative purposes, it’s shown below:

Pic. 3 Source PDF document
Pic. 3 Source PDF document

After setting up the desired signature properties as shown on the next slide, we will get our doc sent to the server, signed there and downloaded back. The demo installation uses https, so there won’t a be a plaintext data exchange happening and we won’t store and use any data sent to our web api except for providing you with signing and watermarking services.

Pic. 4 Applying signature settings
Pic. 4 Applying signature settings

So here we can choose among the existing server keys for signing but the demo installation has only one such key listed (with a word “password” used as its actual password). You can also upload your own key and sign with it if you wish. The purpose of having a set of pre-loaded keys is to provide an organization with a way to share certain functions among employees without actually giving them access to the signing certificates and having common keys in one place for easy management and better protection. 

It might be the case that you’d want to employ a HSM or other means for storing the keys. All these things become possible with a custom setup and implementation of storage modules. Contact us if you are interested to know more. Our web API is based on Apitron PDF Kit product and requires a license for this product to become fully functional. Otherwise it will work in evaluation mode, but the important note is that web API package itself is provided free of charge.

The results of the signing operation are shown below, signature image (if set) takes priority over signature text hence the name and surname represented by the supplied image at the bottom of the page.

Pic. 5 Signed PDF document
Pic. 5 Signed PDF document

Watermarking requires less parameters for now, it can be either a text string or an image as shown below:

Pic. 6 Applying watermark settings
Pic. 6 Applying watermark settings

The image (if set) gets centered on the page and the text gets aligned diagonally along the line coming from the left bottom corner to the top right corner.

Sample watermarked document is shown below:

Pic. 7  Watermarked PDF document
Pic. 7 Watermarked PDF document


The Code


JS code sample showing how to perform the request to the API is provided below, it is the excerpt from the client app referenced in this post, so you can examine its code and find more info there.

[Javascript]
...
var formData = new FormData();
formData.append("signatureText", “your text here”);
formData.append("signatureImage", [image data here]);
formData.append("signingKeyName", “key name here”);
formData.append("signingCertificate", [cert data here]);
formData.append("signingPassword", “cert password here”);
formData.append("signatureBoundary", “115,150,185,190”);
formData.append("signaturePageIndexStart", 0);
formData.append("signaturePageIndexEnd", 0);
$.each(filesToSend,
function (index, value) {
formData.append("sourceFiles" + index, value);
});

// call signing api
$.ajax({ url: “signing api url here”, 
        data: formData, 
        contentType: false, 
        processData: false, 
        type: 'POST',
        success: function (data) {
        getResults(“signing api url here”, data);
        },
        error: function (xhr, textStatus, errorThrown) {
        reportError("Error occured while contacting the server: " + textStatus);
    }
});


We’re performing the REST call here, namely POST the form with parameters describing our signing request, get back the signing task Id and later query the same service using the acquired task Id to get the result. We recommend looking at the sources of the sample app for the detailed explanation on how to make these calls.

Summary


We hope that new web API will facilitate the development of your PDF processing apps. It’s never been so easy to handle PDFs just with a few lines of code and get the serious job done so quickly. An option to have your own installation of the web api free of charge is a great benefit and our professional customer support can always help you with any questions you might have.