Posted 12 May 2022, 9:27 pm EST
- Updated 29 September 2022, 11:09 pm EST
Hello,
As per the developers,
- If you want to change the appearance of unsigned SignatureField you should create a custom appearance
stream, you can use code like this: (also please see the attached project)
GcPdfDocument doc = new GcPdfDocument();
var p = doc.NewPage();
// create an unsigned SignatureField with custom appearance
SignatureField sf = new SignatureField();
doc.AcroForm.Fields.Add(sf);
sf.Widget.Page = p;
sf.Widget.Rect = new RectangleF(20, 40, 200, 60);
// create an appearance stream
FormXObject fxo = sf.Widget.CreateAppearanceContentStream();
GcGraphics g = fxo.Graphics;
// draw appearance on fxoGraphics
var r = fxo.Bounds;
g.FillRectangle(r, Color.Yellow);
TextFormat tf = new TextFormat()
{
FontName = "Tahoma",
FontSize = 14,
};
g.DrawString("Some long text long text long text long text long text long text", tf, r, TextAlignment.Center, ParagraphAlignment.Center, true);
// assign created appearance stream
sf.Widget.AppearanceStreams.Normal.Default = fxo;
doc.Save("unsigned.pdf");
- You can use CR LF to wrap long captions, for example (again you can see the attached project):
sp.SignatureBuilder = new Pkcs7SignatureBuilder(cert);
sp.SignatureAppearance.Caption = "Some\r\nLong\r\nCaption";
sp.SignatureAppearance.Image = Image.FromFile(@"..\..\..\exif.jpg");
sp.SignatureAppearance.CaptionImageRelation = GrapeCity.Documents.Pdf.Annotations.CaptionImageRelation.CaptionAtRight;
- DefaultAppearance is not related to the caption, please see XML comments:
/// <summary>
/// Gets the <see cref="Annotations.DefaultAppearance"/> object that specifies
/// the visual properties (font, font size etc.) used to format the content of this annotation.
/// </summary>
- Regarding to color, I have no idea what application you use to test, I tried to use MSPaint to test, and result (color) is the same, see the attached SS.
Regards,
Prabhat Sharma.
ConsoleApp1.zip