Assign value to a text field

The PDF Creator .NET Library enables you to create secure PDF documents on the fly and to view, print and process existing PDF documents. If you have any questions about PDF Creator .Net, please post them here.
Post Reply
hreith
Posts: 12
Joined: Thu Dec 08 2005

Assign value to a text field

Post by hreith »

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!
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

If you know the old valued of the field you can use the ReachText () method of IacDocument that returns the object reference if the text is found

Hope this helps
hreith
Posts: 12
Joined: Thu Dec 08 2005

Post by hreith »

what if I just know the name of the field I need to change?? there may or may not have been a value in it before.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

If you know the name of the field it's easier, you just set it's "value" attribute.
hreith
Posts: 12
Joined: Thu Dec 08 2005

Post by hreith »

what function do I need to call in order to find ALL the editable fields on a form?
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

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());
}
}
Post Reply