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

后端 未结 2 974
甜味超标
甜味超标 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:

    
    
    
        
            
    

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

            
        
        
           
    

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

            
        
    
    

    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();
    

提交回复
热议问题