如何将数据合并到 XDP 文件并返回 PDF(通过 .NET)?

发布于 2024-08-11 13:35:39 字数 615 浏览 3 评论 0原文

我的团队有一个使用 Adob​​e LiveCycle 设计器创建的模板 (XDP)。

情况:

  • 我们正在替换旧的 Acrobat 表单 (XFDF 格式)使用此 LiveCycle 表单作为更大规模升级的一部分

  • 当前的 Acrobat 表单是 动态填充基本数据 并以 PDF 形式交付给用户 (用户单击链接和 PDF 在预填充的机器上打开 包含基本的人口统计详细信息)

  • 当前流程类似于:用户单击,.NET 应用程序检索数据,.NET 应用程序从文件系统检索 PDF,.NET 应用程序将数据序列化为 XFDF 形式的模板,ASP.NET 应用程序发送以 XFDF 格式返回给用户的 HTTP 响应,用户在 Adob​​e Reader 中查看 PDF

我们希望使用新的 XDP 格式保持大致类似的过程。

根据记录,我们确实可以访问执行此类工作的LiveCycle 服务(例如渲染服务)。也就是说,我们希望在 .NET 中创建这种类型的序列化,原因如下:我们的 LiveCycle 许可证有限,并且由于 LiveCycle 服务位于企业中,因此很难访问它们。

任何想法(甚至“停止这样做,你疯了”)都会受到赞赏。

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) with this LiveCycle
    form as part of a much larger upgrade

  • The current Acrobat form is
    dynamically populated with basic data
    and delivered to the user as a PDF
    (the user clicks a link and a PDF
    opens on their machine pre-populated
    with basic demographic details)

  • The current process looks something like: user clicks, .NET app retrieves data, .NET app retrieves PDF from file system, .NET app serializes data into template in XFDF form, ASP.NET app sends an HTTP response back to the user in XFDF format, the user views the PDF in Adobe Reader

We would like to maintain a roughly analogous process with the new XDP format.

For the record, we DO have access to the LiveCycle services that do this type of work (e.g. the Render service). That said, we would like to create this type of serialization in .NET for a few reasons: we have limited LiveCycle licenses and will struggle to access the LiveCycle services due to their location in the enterprise.

Any thoughts (even "stop doing that, you're insane") are appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奢华的一滴泪 2024-08-18 13:35:39

嘿嘿,抱歉回复慢了,没看到。

创建 PDF。将其编码为 base64。

创建一个文本文件 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>

在此处插入作为动态数据的 XML,与 PDF 中的动态字段相匹配。

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

不要在标签后放置任何字符,插入 base64 编码的 PDF。

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

而且,您瞧,您拥有了有效的 XDP。 Adobe Reader 将接受此信息并显示包含您的值的 PDF。

在 Java 中,如果您有一个包含连接详细信息的属性,则以下代码可以使用 Livecycle 将 XDP 转换为 PDF,尽管在 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();

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();
慢慢从新开始 2024-08-18 13:35:39

听起来你正在寻找客户端渲染 - 我从来没有真正能够以可行的方式使用它。考虑到您正在 .Net 中工作,这可能会让事情变得不可能。

在我看来,您最好的选择肯定是使用 Forms ES 附带的渲染服务。可能没有多大帮助,但是嘿:)

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文