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

foreach (Field field in pdfLetter.Document.Form) through a PDF with subform only seeing TopmostSubform[0]

$
0
0
I am using the latest Aspose.Pdf.net lib, I am upgraded from Aspose.Pdf.kit

The following is just a code snippet:  What I am trying to do is loop through a PDF fill some fields and add an image stamp everywhere there is a signature field. This is a work around sugested by Aspose support, which is working for 99.9% of my PDFs without an issue. However, one of my PDF's has a subform. When I loop through the PDF with the subform the Field.FullName is always TopmostSubform[0]. How do I loop through the subform fields. The solution will need to work for a PDF that does and does not have a subform.          

            foreach (Field field in pdfLetter.Document.Form)
            {
              string shortFieldName;
              const string fieldPrefix = "TopmostSubform[0]";  
              shortFieldName = field.FullName;
              
              if (shortFieldName.Equals(SignatureFieldName))
              {
                if (!string.IsNullOrEmpty(signatureImageFilename))
                {
                  SignatureField sf = field as SignatureField;
                  if (sf != null)
                  {
                    //pdfLetter.FillImageField(fieldName, signatureImageFilename);
                    int signaturePage = field.PageIndex;
                    //create image stamp
                    ImageStamp imageStamp = new ImageStamp(signatureImageFilename);
                    imageStamp.Background = false;
                    imageStamp.XIndent = sf.Rect.LLX;
                    imageStamp.YIndent = sf.Rect.LLY;
                    imageStamp.Height = sf.Rect.Height;
                    imageStamp.Width = sf.Rect.Width;
                    //add stamp to particular page
                    pdfLetter.Document.Pages[signaturePage].AddStamp(imageStamp);
                  }
                }
              }
            } 

Viewing all articles
Browse latest Browse all 3131

Trending Articles