Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically enable Adobe PDF usage rights

Is there any way to programmatically enable Adobe PDF usage rights from .net code ? I'm using ITextSharp library to fill an XFA Form with XML Data (generated from app), but the output PDF does not have usage rights enabled, thus the users cannot interact with it (that wouldn't normally be a problem, BUT the original PDF is gov supplied, and the user must click some validation buttons, and that process is user/company specific)

This could be manually accomplished from Adobe Reader but you have to have an adobe acrobat professional licence..

Google is saying that "Only Adobe products can do that" .. (http://old.nabble.com/Enable-Adobe-Reader-usage-rights-td14276927.html)

string pathPDF = @"C:\original.pdf";
string pathCreated = @"C:\created.pdf";
string pathXml = @"C:\data.xml";

using (PdfStamper stamper = new PdfStamper(new PdfReader(pathPDF), System.IO.File.OpenWrite(pathCreated)))
{
    stamper.FormFlattening = false;
    stamper.AcroFields.Xfa.FillXfaForm(pathXml);

    stamper.Close();
}
like image 575
danmaier2010 Avatar asked Jan 20 '23 06:01

danmaier2010


1 Answers

The only way to do it programitically is to use Adobe Reader Extension Server. You can review Adobe whitepaper here: http://www.adobe.com/sea/products/server/readerextensions/pdfs/readerextensionsserver_ds.pdf

In the case above you would use iTextSharp to create Pdf document and then use Adobe Reader Extension Server to allow Pdf document to have extended functionality in Adobe Reader.

However, there is a small window that allows you to work with iTextSharp and fill-in already Reader-enabled PDF documents. If you have such Pdf document (Reader Enabled), then you can use iText/iTextSharp to fill in XFA data. You can check example here: http://itextpdf.com/examples/iia.php?id=166

Good luck!

like image 114
Dmitry Avatar answered Jan 29 '23 05:01

Dmitry