Quote:
I think it is a feature, not a bug: when setting a property (e.g. Text) you have to make sure that all related properties (Filter in this case) also get set accordingly.
You can also assign a filtered object to the Text property.
I think, we might have a misunderstanding here.
Why should the average user had to deal with filters and the like, when setting the "Text"-Property of a PdfTextField ?
What kind of "filtered object" should that be ?
To clarify my point, the code-flow that leads to the problem:
- user sets the Text-Property of a PdfTextField
- from the PdfSharp sources, the Setter of the Text-Property :
Code:
set { Elements.SetString(Keys.V, value); RenderAppearance(); } //HACK in PdfTextField
- RenderAppearance creates a new ApperanceStream (or uses the existing one) and sets its value :
Quote:
xobj.Stream.Value = new RawEncoding().GetBytes(s);
The last line may cause a problem when the Stream already exists with a filter present.
This all happens inside of PdfSharp, so i thought, i point this out.
Quote:
I think it would be nice to have a helper method that sets both Text and Filter at the same time.
I agree, but not so much for the Text-Property of a PdfTextField, but more for the Value-Property of a PdfStream.
Setting the Text-Property should be a transparent operation for the user.