Programmatically enable Adobe PDF usage rights

后端 未结 5 1916
眼角桃花
眼角桃花 2021-01-19 13:14

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

相关标签:
5条回答
  • 2021-01-19 13:29

    No. Adobe uses Strong Crypto to ensure it... PPK I believe.

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

    That's because only Adobe products can do that. You can pay for some Acrobat server product or other... $$$... but that's it.

    0 讨论(0)
  • 2021-01-19 13:30

    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!

    0 讨论(0)
  • 2021-01-19 13:36

    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()
    
    0 讨论(0)
  • 2021-01-19 13:43

    you can complete it using PdfStamper when using PdfStamper use thi code

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

    if the form is Reader Extension enabled it will work

    0 讨论(0)
  • 2021-01-19 13:52

    Currently only 2 products can enable usage rights:

    • Adobe Acrobat - for less that 500 users
    • Adobe LiveCycle Reader Extensions - more than 500 users

    There have been some findings regarding this feature here.

    0 讨论(0)
提交回复
热议问题