Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

How to populate an image field using XFA.SetFieldImage()

$
0
0
Hello,

I am attempting to open a PDF, find all the image fields of a certain name, then populate each image field with the same image.  For example, a single PDF may have any number of pages and each page may have multiple image fields that need to be populated with the same image.  Unfortunately, nothing I have tried so far is working.  

The layout of the PDF is as follows:

Page 1
LogoField1
LogoField2

Page 2
LogoField1
LogoField2

Page 3
LogoField1
LogoField2...

...and so on.

Here is the code I am using:

Document doc = new Document("test.pdf");
FileStream fs = new FileStream("logo.png", FileMode.Open, FileAccess.Read);

string[] fieldNames = (from x in doc.Form.XFA.FieldNames
                              where x.Contains("LogoField")
                              select x.ToString()
                                  ).ToArray();

foreach (var x in fieldNames)
{
 doc.Form.XFA.SetFieldImage(x.ToString(), fs);
}

doc.Save("test.pdf");

I do not get an error, just no images.  Any assistance you can offer would be extremely helpful. 

Thank you.

Viewing all articles
Browse latest Browse all 3131

Trending Articles