新签名字段旋转 90 度

New Signature Field Rotated 90 Degrees

我可以使用注释在 PDF 上添加新的签名块,但它总是相对于页面旋转 90*。在添加注释之前,我曾尝试在注释上使用 .Rotate 方法,但那没有任何作用。我还旋转了 PDF 模板,添加的签名字段保持相同的相对 90* 方向。我还更改了矩形点,但似乎对旋转没有任何影响。我不想签署 PDF...我只想添加一个空白的签名字段供其他方稍后签名。

//Get location to the field where we will place the signature field
AcroFields.FieldPosition NewPosition = fields.GetFieldPositions("DESC_0_" + (itemno + 1).ToString())[0];
float l1 = NewPosition.position.Left;
float r1 = NewPosition.position.Right;
float t1 = NewPosition.position.Top;
float b1 = NewPosition.position.Bottom;

PdfFormField field = PdfFormField.CreateSignature(pdfStamper.Writer);
field.FieldName = "G4_Signature";

// Set the widget properties
field.SetWidget(new iTextSharp.text.Rectangle(r1, t1, l1, b1), PdfAnnotation.HIGHLIGHT_NONE);
field.Flags = PdfAnnotation.FLAGS_PRINT;
// Add the annotation
pdfStamper.AddAnnotation(field, 1);

文档中的页面使用 旋转 页面字典条目旋转。以后在创建其他人填写的字段时,如果希望字段内容有效地竖直显示,则必须在字段中添加提示以指示反向旋转。

您可以通过设置字段的 MKRotation 属性来做到这一点:

field.Flags = PdfAnnotation.FLAGS_PRINT;
// Add a hint for upright signature creation
field.MKRotation = 90;
// Add the annotation
pdfStamper.AddAnnotation(field, 1);

这会在字段的外观特征字典MK中创建一个值为90的旋转条目R

对于背景:

MK dictionary (Optional) An appearance characteristics dictionary (see Table 189) that shall be used in constructing a dynamic appearance stream specifying the annotation’s visual presentation on the page.

The name MK for this entry is of historical significance only and has no direct meaning.

(Table 188 – Additional entries specific to a widget annotation - in ISO 32000-1)

R integer (Optional) The number of degrees by which the widget annotation shall be rotated counterclockwise relative to the page. The value shall be a multiple of 90. Default value: 0.

(Table 189 – Entries in an appearance characteristics dictionary - in ISO 32000-1)