I am reading up a text file that contains the Name and Value of an editable text field on the PDF form. How do I find the name of the editable text field and set the value of it to something else?
Thanks!
Assign value to a text field
Hello,
Below is a code that retreive all the objects in a PDF file, you can edit this code to retreive only Field objects.
Hope this helps.
private void RetrieveObjects_Click(object sender, System.EventArgs e)
{
try
{
System.Collections.ArrayList listobj = new ArrayList(); // listobj is an array list of objects
System.IO.FileStream testfile = new System.IO.FileStream ("TestFile.pdf",FileMode.Open, FileAccess.Read,FileShare.Read);
using ( IacDocument document = new IacDocument( null ) )
{
document.Open (testfile,"");
IacPage page1 = document.GetPage(1);
Amyuni.PDFCreator.IacAttribute attribute = page1.AttributeByName("Objects");
listobj = (System.Collections.ArrayList) attribute.Value;
Amyuni.PDFCreator.IacObject iacObj;
foreach ( object o in listobj )
{
iacObj = (Amyuni.PDFCreator.IacObject) o;
MessageBox.Show( "Name: " + iacObj.Name + " " + "Type: " +iacObj.AttributeByName("ObjectType").Value.ToString() );
}
}
}
catch(IacException acEx)
{
MessageBox.Show (acEx.ToString());
}
}
Below is a code that retreive all the objects in a PDF file, you can edit this code to retreive only Field objects.
Hope this helps.
private void RetrieveObjects_Click(object sender, System.EventArgs e)
{
try
{
System.Collections.ArrayList listobj = new ArrayList(); // listobj is an array list of objects
System.IO.FileStream testfile = new System.IO.FileStream ("TestFile.pdf",FileMode.Open, FileAccess.Read,FileShare.Read);
using ( IacDocument document = new IacDocument( null ) )
{
document.Open (testfile,"");
IacPage page1 = document.GetPage(1);
Amyuni.PDFCreator.IacAttribute attribute = page1.AttributeByName("Objects");
listobj = (System.Collections.ArrayList) attribute.Value;
Amyuni.PDFCreator.IacObject iacObj;
foreach ( object o in listobj )
{
iacObj = (Amyuni.PDFCreator.IacObject) o;
MessageBox.Show( "Name: " + iacObj.Name + " " + "Type: " +iacObj.AttributeByName("ObjectType").Value.ToString() );
}
}
}
catch(IacException acEx)
{
MessageBox.Show (acEx.ToString());
}
}