- Home
- Forum
- ASP.NET Web Forms (Classic)
- CreateStyle
CreateStyle
Hi,
I am evaluating the EssentialPDF for purchase. Can someone explain to me how to user the IPDFForm.CreateStyle() method? Here''s what I''m trying to do:
I have a PDF form with two fields. I need to programmatically discover the field names, set the value of the fields, and set their font and color properties as well. I have successfully set the values, but the font and colors are not working for me. Most likely I am simply leaving out some necessary code.
I have tried this:
// set field value - this works great
doc.form.Fields["field1"].Value = "new value";
// set BackColor - this doesn''t work
IPDFFieldStyle myStyle = doc.CreateStyle();
myStyle.BackColor = new PDFColor(Color.Red);
doc.form.Fields["field1"].Style = myStyle;
If I try to set doc.form.Fields["field1"].Style.BackColor property directly, I get an error that it''s not set to an instance of an object.
Any help would be greatly appreciated. Thanks.
SIGN IN To post a reply.
5 Replies
AJ
Ajish
Syncfusion Team
June 5, 2006 06:10 AM UTC
Hi Matt,
Thank you for your interest in Essential PDF. The coding that you use to craete a style and set to the form field are perfect. But
currently we do not have any support for setting style of a loaded document it works only with the generation of new form fields. Currently it is only possible to get/set values, name and type of the form fields of the loaded document. However we are working on this issue and it should be available very soon and I will send you an update as soon as it is available.
Here is code to set/ get the form field type and name.
foreach( IPDFField field in ldoc.Form.Fields )
{
IPDFLoadedField lfield = field as IPDFLoadedField;
MessageBox.Show("Field Name: " +lfield.Name + "\nField Type: "+lfield.Type.ToString());
if( lfield != null && lfield.Type == PDFFieldTypeEnum.TextField )
{
lfield.Value = "Hello";
}
}
and here is a sample for your reference: FillForm.zip
Please let me know if you have any other questions.
Thanks,
Ajish.
ME
Matt Ellison
June 5, 2006 05:02 PM UTC
Hi Ajish,
Thanks for the prompt reply. Do you have a timeframe for when this functionality would be available? My project is time-sensitive but I like your product and would like to use it if this will be added soon.
In the meantime, as a workaround, please let me know if this would work:
(1) load the existing PDF form
(2) iterate through the existing form fields
(3) for each field, create a new field matching the exact size and location (bounds) of the existing field.
(4) set the value, font, and color properties of the newly created field
(5) delete/remove the original existing form field
(6) add the newly created field to the existing PDF, thereby replacing the original form field
If this sounds like a valid workaround please let me know and if possible what the code should be to do this.
Thanks for your help,
Matt
AJ
Ajish
Syncfusion Team
June 6, 2006 02:40 PM UTC
Hi Matt,
Sorry for the delay in getting back to you. Currently it is only possible to get/set Value, Name and get the type of form field. But it is not possible to change the properties or remove field from form field collection. However I send you an update regarding the timeframe as soon as possible.
Thanks,
Ajish.
ME
Matt Ellison
June 7, 2006 10:45 PM UTC
OK, thanks for the update. Please let me know the timeframe for the next release as soon as possible. Thanks,
Matt
>Hi Matt,
>
>Sorry for the delay in getting back to you. Currently it is only possible to get/set Value, Name and get the type of form field. But it is not possible to change the properties or remove field from form field collection. However I send you an update regarding the timeframe as soon as possible.
>
>Thanks,
>Ajish.
AD
Administrator
Syncfusion Team
June 12, 2006 06:59 PM UTC
Hi Matt,
After investigating this issue, the development team has informed me that it would not be possible to implement this functionality since the form''s fields appearance is stored in the PDF file as graphics primitives and we currently do not parse the graphics primitives when we read an existing PDF file. Currently the only possible solution is to get the bounds of the field and draw on top of it. Here is a sample
FillForm_2003_6c712252.zip
Issues with the sample
--------------------------
1) Currently it is not possible to get the page associated with a form field but this functionality can be added easily.
2) This approach does not permit modifying the font or color of text.
Sorry for the confusion. Please let me know if you have any questions.
Best regards,
Stephen.
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
-
ME Matt Ellison
- Jun 5, 2006 01:17 AM UTC
- Jun 12, 2006 06:59 PM UTC