How can I merge data into an XDP file and return a PDF (via .NET)?

后端 未结 2 975
甜味超标
甜味超标 2021-01-13 02:37

My team has a template (XDP) that we\'ve created with the Adobe LiveCycle designer.

The situation:

  • We are replacing an old Acrobat form (XFDF format

相关标签:
2条回答
  • 2021-01-13 03:22

    Hey, sorry for the slow reply, didn't see this.

    Create the PDF. Encode it as base64.

    Create a text file, foo.xdp:

    <?xml version='1.0' encoding='UTF-8'?>
    <?xfa generator='AdobeDesigner_V7.0' APIVersion='2.2.4333.0'?>
    <xdp:xdp xmlns:xdp='http://ns.adobe.com/xdp/'>
        <xfa:datasets xmlns:xfa='http://www.xfa.org/schema/xfa-data/1.0/'>
            <xfa:data>
    

    Insert the XML here that is your dynamic data, matching the dynamic fields in the PDF.

            </xfa:data>
        </xfa:datasets>
        <pdf xmlns=\"http://ns.adobe.com/xdp/pdf/\"><document>
           <chunk>
    

    Without putting any characters after the tag, insert the base64 encoded PDF.

            </chunk>
        </document></pdf>
    </xdp:xdp>
    

    And, lo and behold, you have a valid XDP. Adobe Reader will accept this and display the PDF with your values in it.

    In Java, if you have a Properties with the connection details in it, the following code can use Livecycle to turn an XDP to a PDF, although your mileage might vary in C#.

            // Create a ServiceClientFactory object
            ServiceClientFactory myFactory = ServiceClientFactory
                    .createInstance(connectionProperties);
    
            // Create a PDF Utility client
            PDFUtilityServiceClient pdfClient = new PDFUtilityServiceClient(myFactory);
    
            // Specify an XDP file to convert to a PDF document
            ByteArrayInputStream bais = new ByteArrayInputStream(xdp.getBytes("ASCII"));
            Document inDoc = new Document(bais);
    
            // Convert the XDP file to a PDF document
            Document pdf = pdfClient.convertXDPtoPDF(inDoc);
    
            // Return the PDF as an InputStream.
            return pdf.getInputStream();
    
    0 讨论(0)
  • 2021-01-13 03:36

    Sounds like you're looking for client-side rendering - something that I've never really been able to use in a workable fashion. And given that you're working in .Net it'll probably make things impossible..

    In my opinion your best bet will definitely be to use the render service that comes with Forms ES. Probably doesn't help much, but hey :)

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