0

问题:

我试图让图像显示在使用 XDP 文件生成的 PDF 上。

我目前正在尝试:

我有一个从 PDF 导出的 XDP 文件。我在 pdf 上有一个带有“my_image”标签的文本框。这是我用来对作为“my_image”标签的值插入的字符串进行编码的代码。

var bytes = System.IO.File.ReadAllBytes(@"C:\image.jpg");
var data = Convert.ToBase64String(bytes);

当我使用 XDP 启动 PDF 时,图像不显示,只显示 Base64 编码字符串值。

有任何想法吗?

4

1 回答 1

1

我在 LiveCycle Designer 中制作了一个简单的 PDF,其中包含一个Image Field名为ImageField1. 我使用与您几乎相同的代码来创建 base64 编码图像,只是我包含了从技术上讲不需要的换行:

var testImage = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Untitled.png");
var bytes = System.IO.File.ReadAllBytes(testImage);
var data = Convert.ToBase64String(bytes, Base64FormattingOptions.InsertLineBreaks);

总之,这是我的 XDP 文件,适用于我的简单 PDF。我知道这不是一个完整的答案,但希望您可以将适合我的内容与您的代码进行比较。

<?xml version="1.0" encoding="UTF-8"?>
<?xfa generator="XFA2_4" APIVersion="3.0.11111.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
><topmostSubform
><ImageField1 xfa:contentType="image/png" href=""
>iVBORw0KGgoAAAANSUhEUgAAAMYAAAC2CAYAAACCufKcAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAApDSURBVHhe7Z27j9xUFIf5Q+hCRarQbZcKKlIl
VahIFSpEgyiQKJAoEAVSikgUSClSREoRpUE0URpEE6VBNFEqqFYiy+SxWfIa9jfBxDvr8T1n5o59
fc9naYXI2h6f79xv73v81pwDAhA4RuAtmEAAAscJIAalAgIdBBCDYgEBxKAMQMBGgBrDxomzghFA
jGAJJ1wbAcSwceKsYAQQI1jCCddGADFsnDgrGAHECJZwwrURQAwbJ84KRgAxg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ufRJOJAGJkAslt
6iKAGHXlk2gyEUCMTCC5TV0EEKOufBJNJgKIkQkkt6mLwL8Ifb+k376AhQAAAABJRU5ErkJggg==</ImageField1
></topmostSubform
></xfa:data
></xfa:datasets
>
<pdf href="Untitled1_distributed.pdf" xmlns="http://ns.adobe.com/xdp/pdf/"
/></xdp:xdp>
于 2011-10-18T22:31:08.220 回答