Programmatically Enable Adobe PDF Use Rights

Is there a way to programmatically enable Adobe PDF usage rights from .net code? I use the ITextSharp library to populate the XFA form with XML data (generated from the application), but the output PDF does not have permission to use, so users cannot interact with it (which would normally not be a problem, BUT the original PDF is provided, and the user must click a few check buttons, and this process depends on the user / company)

This can be done manually from Adobe Reader, but you must have a professional Adobe Acrobat license.

Google says that "only Adobe products can do this" .. ( 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(); } 
+4
source share
5 answers

The only way to do this programmatically is to use the Adobe Reader Extension Server. You can view the Adobe white paper here: http://www.adobe.com/sea/products/server/readerextensions/pdfs/readerextensionsserver_ds.pdf

In the above case, you should use iTextSharp to create the PDF, and then use the Adobe Reader Extension Server to allow the PDF to have advanced functionality in Adobe Reader.

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

Good luck

+5
source

Currently, only 2 products may include usage rights:

  • Adobe Acrobat - less than 500 users.
  • Adobe LiveCycle Reader Extensions - Over 500 Users

There were some conclusions regarding this feature here .

+2
source

No. Adobe uses Strong Crypto to provide this ... PPK I reckon.

  Google is saying that "Only Adobe products can do that" 

This is because only Adobe products can do this. You can pay for some Acrobat server product or another ... $$$ ... but what is it.

+1
source

This worked for me:

  string TempFilename = Path.GetTempFileName(); PdfReader pdfReader = new PdfReader(FileName); //PdfStamper stamper = new PdfStamper(pdfReader, new FileStream(TempFilename, FileMode.Create)); PdfStamper stamper = new PdfStamper(pdfReader, new FileStream(TempFilename, FileMode.Create), '\0', true); AcroFields fields = stamper.AcroFields; AcroFields pdfFormFields = pdfReader.AcroFields; foreach (KeyValuePair<string, AcroFields.Item> kvp in fields.Fields) { string FieldValue = GetXMLNode(XMLFile, kvp.Key); if (FieldValue != "") { fields.SetField(kvp.Key, FieldValue); } } stamper.FormFlattening = false; stamper.Close(); pdfReader.Close() 
+1
source

you can execute it with PdfStamper when using PdfStamper use this code

 PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream( newPath, FileMode.CreateNew, FileAccess.Write), '\0', true); 

if the form is included in the Reader Extension, it will work

0
source

Source: https://habr.com/ru/post/1343183/


All Articles