We are pleased to announce the new GrapeCity Documents v4.2 Maintenance Release 4.2.0.719/2.2.15 (GcPdfViewer). In this release, we make some new additions to our existing API to cater to our customer requests. Check out the new highlights below!

Try GrapeCity Documents for PDF

Download the latest version of GrapeCity Documents for PDF

Download Now!

GrapeCity Documents for PDF (GcPdf)

Digital Signature Enhancements

Further enhancements have been made to Digital Signatures support in GcPdf.

Digitally Sign PDF with PAdES (PDF Advanced Electronic Signatures)

GcPdf now supports PAdES standard for signing PDF documents. In this release, we support the PAdES B-B and B-T levels. Two new static utility methods, 'CreatePAdES_B_B(..)', and 'CreatePAdES_B_T(..)' have been added to the SignatureProperties class.

Use these methods to create a SignatureProperties instance that can be used to sign a PDF with a respective PAdES level signature. Both methods can be passed a chain of certificates (the first certificate is used for signing).

The following code snippet shows how to use these methods:

GcPdfDocument doc = new GcPdfDocument();
doc.Load(fs);

X509Certificate2 cert = new X509Certificate2("User.pfx", "**");
SignatureProperties sp = SignatureProperties.CreatePAdES_B_B(cert);
sp.SignatureAppearance.Caption = "PAdES B-B";
sp.SignatureField = doc.AcroForm.Fields[0];
doc.Sign(sp, "signed_PAdES_B_B.pdf");

gc pdf

The following APIs have been added to apply a PAdES B-B and B-T levels:

  • The new ISignatureBuilder, IPkcs7SignatureGenerator interfaces allow users to provide custom implementations of digital signatures
  • The class Pkcs7SignatureBuilder implements ISignatureBuilder, and can be used to create PDF standard signatures in format PKCS#7, with levels B-B and B-T
  • Now ETSI_CAdES_detached signatures can be created when Pkcs7SignatureBuilder.Format property is set to SignatureFormat.ETSI_CAdES_detached
  • Certificate Revocation Lists can be embedded into the signature using the new Pkcs7SignatureBuilder.Crls property
  • OCPS information can be embedded into the signature – using Pkcs7SignatureBuilder.IncludeOcsp property
  • A full chain of certificates can be embedded into the signature (not only the signing certificate) using Pkcs7SignatureBuilder.CertificateChain property
  • ISignatureParser interface enables to retrieve the entire certificate chain from a signature

Help

Sign PDF Documents with .p12 Extension Certificate

You can now sign existing signatures with a .p12 extension certificate. See the following code for a demonstration:

using (FileStream fs = new FileStream(@"AdobePDFWithEmptySignatureField.pdf", FileMode.Open))
{
        GcPdfDocument doc = new GcPdfDocument();
        doc.Load(fs);

        SignatureProperties sp = new SignatureProperties();
        sp.SignatureBuilder = new Pkcs7SignatureBuilder()
        {
            CertificateChain = SecurityUtils.GetCertificateChain("1571753451.p12", "**"),
        };
        sp.SignatureField = doc.AcroForm.Fields[0];

        doc.Sign(sp, "signed.pdf");
}

Help

Embed a Full Certificate Chain When Signing PDF Documents

The new Pkcs7SignatureBuilder.CertificateChain object allows you to embed a full chain of certificates into the signature.

using (FileStream fs = new FileStream(@"AdobePDFWithEmptySignatureField.pdf", FileMode.Open))
 {
       GcPdfDocument doc = new GcPdfDocument();
       doc.Load(fs);

       SignatureProperties sp = new SignatureProperties();
       sp.SignatureBuilder = new Pkcs7SignatureBuilder()
       {
            CertificateChain = SecurityUtils.GetCertificateChain("1571753451.p12", "**"),
        };
        sp.SignatureField = doc.AcroForm.Fields[0];
        doc.Sign(sp, "signed.pdf");
}
Sign a Document Using a Certificate from Azure KeyVault

We now support signing a PDF document using Azure KeyVault. This can be done using AzureSignatureGenerator class added for demo purposes. You can find full implementation in this demo.

Sign a Document Using a USB Token

When a PDF is signed, you can store the certificate in different locations, e.g., on a hardware 'token' etc. Some common interfaces allow working with such certificate sources.

These will now be supported in GcPdf. The Pkcs11SignatureGenerator class helps sign a PDF using a USB token and has been added for demo purposes. Please find the full implementation of the class in this demo.

GrapeCity Documents PDF Viewer (GcPdfViewer)

In v4.2 release, we introduced the API to add layers (optional content) to PDF documents. In this release, we now add support showing/hiding layers in our JavaScript based GrapeCity Documents PDF Viewer (GcPdfViewer). The viewer provides viewer.addLayersPanel() method, to add layers panel to the viewer.

add layers

In addition, the viewer API adds new optionalContentConfig property that allows users to:

  • Get information about the available layers
  • Control the visibility of individual layers from code

The following code snippets demonstrate how to use the new property:

// Use the addLayersPanel method to add Layers panel to the viewer UI:
viewer.addLayersPanel();
...

// Use the optionalContentConfig property to print information about the available layers to the console:
const config = await viewer.optionalContentConfig;
console.table(config.getGroups());
...

// Use the optionalContentConfig property to toggle layers visibility from code:
const config = await viewer.optionalContentConfig;
// Hide the optional content group (layer) with id "13R":
config.setVisibility("13R", false);
// Repaint visible pages:
viewer.repaint();

A few other methods have been added to the viewer:

  • openPanel(): Opens a side panel
  • closePanel(): Closes the side panel
  • resetChanges(): Resets the document to its original state, discarding all changes
  • setPageRotation(pageIndex, rotation): Enables users to rotate a specific page in the PDF. This method requires SupportApi. Valid values for rotation are 0, 90, 180, and 270 degrees
  • getPageRotation(pageIndex): Gets the rotation value for a specified page

Check more details below.

Help | Demo

GrapeCity Documents for Word (GcWord)

Restart Numbered Lists

A new method has been added to the Paragraph class: RestartList(int? startNumberingValue = null). This method will restart the list numbering on the current paragraph. If the optional parameter is omitted, numbering on the current list will be restarted. Otherwise, a new list will be created.

Note that the current paragraph must belong to a numbered list. If not, an exception will be thrown.

The following code demonstrates how to restart the list at various levels:

GcWordDocument doc = new GcWordDocument();
var pars = doc.Body.Sections.First.GetRange().Paragraphs;
pars.Add("A numbered list with 3 levels:");
// A ListTemplate is used to make paragraphs part of a list:
var myListTemplate = doc.ListTemplates.Add(BuiltInListTemplateId.NumberDefault, "myListTemplate");

// Add a 3-level numbered nested list:
addItem("Top item 1", 0);
addItem("Top item 2", 0);
addItem("Top item 3", 0);
addItem("Nested item 1", 1);
addItem("Nested item 2", 1);
addItem("Double nested item 1", 2);
addItem("Double nested item 2", 2);
// Restart a list with default numbering:
addItem("Double nested item 3 - restart at 'i'", 2).RestartList();
addItem("Double nested item 4", 2);
addItem("Double nested item 5", 2);
addItem("Nested item 3", 1);
addItem("Nested item 4", 1);
addItem("Nested item 5", 1);
addItem("Nested item 6", 1);
// Restart a letter-numbered ("a, b, c,...") list at letter 'c':
addItem("Nested item 7 - restart at 'c'", 1).RestartList(3);
addItem("Nested item 8", 1);
addItem("Nested item 9", 1);
addItem("Top item 4", 0);
addItem("Top item 5", 0);

list

Help | Demo

Try GrapeCity Documents for Word

Download the latest version of GrapeCity Documents for Word

Download Now!