InsertSignatureLine

InsertSignatureLine(SignatureLineOptionsRelativeHorizontalPosition, double, RelativeVerticalPosition, double, WrapType)

Inserts a signature line at the specified position.

public Shape InsertSignatureLine(SignatureLineOptions signatureLineOptions, 
    RelativeHorizontalPosition horzPos, double left, RelativeVerticalPosition vertPos, double top, 
    WrapType wrapType)
ParameterTypeDescription
signatureLineOptionsSignatureLineOptionsThe object that stores parameters of creating signature line.
horzPosRelativeHorizontalPositionSpecifies where the distance to the signature line is measured from.
leftDoubleDistance in points from the origin to the left side of the signature line.
vertPosRelativeVerticalPositionSpecifies where the distance to the signature line measured from.
topDoubleDistance in points from the origin to the top side of the signature line.
wrapTypeWrapTypeSpecifies how to wrap text around the signature line.

Return Value

The signature line node that was just inserted.

Remarks

You can change the image size, location, positioning method and other settings using the Shape object returned by this method.

Examples

Shows how to insert an inline signature line into a document.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

SignatureLineOptions options = new SignatureLineOptions
{
    Signer = "John Doe",
    SignerTitle = "Manager",
    Email = "johndoe@aspose.com",
    ShowDate = true,
    DefaultInstructions = false,
    Instructions = "Please sign here.",
    AllowComments = true
};

builder.InsertSignatureLine(options, RelativeHorizontalPosition.RightMargin, 2.0,
    RelativeVerticalPosition.Page, 3.0, WrapType.Inline);

// The signature line can be signed in Microsoft Word by double clicking it.
doc.Save(ArtifactsDir + "DocumentBuilder.SignatureLineInline.docx");

See Also


InsertSignatureLine(SignatureLineOptions)

Inserts a signature line at the current position.

public Shape InsertSignatureLine(SignatureLineOptions signatureLineOptions)
ParameterTypeDescription
signatureLineOptionsSignatureLineOptionsThe object that stores parameters of creating signature line.

Return Value

The signature line node that was just inserted.

Examples

Shows how to sign a document with a personal certificate and a signature line.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

SignatureLineOptions signatureLineOptions = new SignatureLineOptions
{
    Signer = "vderyushev",
    SignerTitle = "QA",
    Email = "vderyushev@aspose.com",
    ShowDate = true,
    DefaultInstructions = false,
    Instructions = "Please sign here.",
    AllowComments = true
};

SignatureLine signatureLine = builder.InsertSignatureLine(signatureLineOptions).SignatureLine;
signatureLine.ProviderId = Guid.Parse("CF5A7BB4-8F3C-4756-9DF6-BEF7F13259A2");

Assert.False(signatureLine.IsSigned);
Assert.False(signatureLine.IsValid);

doc.Save(ArtifactsDir + "DocumentBuilder.SignatureLineProviderId.docx");

SignOptions signOptions = new SignOptions
{
    SignatureLineId = signatureLine.Id,
    ProviderId = signatureLine.ProviderId,
    Comments = "Document was signed by vderyushev",
    SignTime = DateTime.Now
};

CertificateHolder certHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw");

DigitalSignatureUtil.Sign(ArtifactsDir + "DocumentBuilder.SignatureLineProviderId.docx", 
    ArtifactsDir + "DocumentBuilder.SignatureLineProviderId.Signed.docx", certHolder, signOptions);

// Re-open our saved document, and verify that the "IsSigned" and "IsValid" properties both equal "true",
// indicating that the signature line contains a signature.
doc = new Document(ArtifactsDir + "DocumentBuilder.SignatureLineProviderId.Signed.docx");
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
signatureLine = shape.SignatureLine;

Assert.True(signatureLine.IsSigned);
Assert.True(signatureLine.IsValid);

See Also