Spire.Office 5.12.8

Spire.Office 5.12.8 is released

We are happy to announce the release of Spire.Office 5.12.8. This versions contains multifarious new gorgeous features. For instance, Spire.Doc supports getting the compared differences between two Word documents, Spire.XLS supports adjusting the polyline position of the elebow arrow, Spire.PDF supports adding page label, as well as supports digitally signing PDF through external services and many more. In addition, a lot of bugs have also been successfully fixed. More details are given below.

In this version, the most recent versions of Spire.Doc, Spire.PDF, Spire.XLS, Spire.Presentation, Spire.Email, Spire.DocViewer, Spire.PDFViewer, Spire.Spreadsheet, Spire.OfficeViewer, Spire.DataExport, Spire.Barcode are included.

Dll Versions:

  • Spire.Doc.dll v8.12.14
  • Spire.Pdf.dll v6.12.20
  • Spire.XLS.dll v10.12.0
  • Spire.Email.dll v3.9.1
  • Spire.DocViewer.Forms.dll v5.1.1
  • Spire.PdfViewer.Forms.dll v5.12.5
  • Spire.PdfViewer.Asp.dll v5.12.5
  • Spire.Presentation.dll v5.12.2
  • Spire.Spreadsheet v4.12.1
  • Spire.OfficeViewer.Forms.dll v5.12.8
  • Spire.Barcode.dll v4.11.0
  • Spire.DataExport.dll v4.1.9
  • Spire.DataExport.ResourceMgr.dll v2.1.0
  • Spire.License.dll v1.3.8
Click the link to get the version Spire.Office 5.12.8:
More information of Spire.Office new release or hotfix:

Here is a list of changes made in this release

Spire.Doc

Category ID Description
New Feature SPIREDOC-4965 Supports getting the differences compared between two Word documents.
New Feature SPIREDOC-4965 Supports obtaining author and date time of revisions.
Document doc1 = new Document();
doc1.LoadFromFile("C:/1.docx");

Document doc2 = new Document();
doc2.LoadFromFile("C:/2.docx");

doc1.Compare(doc2, "spire.support");

foreach (Section sec in doc1.Sections)
{
    foreach (DocumentObject docItem in sec.Body.ChildObjects)
    {
        if (docItem is Paragraph)
        {
            Paragraph para = docItem as Paragraph;
            if (para.IsInsertRevision)
            {
                EditRevision insRevison = para.InsertRevision;
                EditRevisionType insType = insRevison.Type;
                string insAuthor = insRevison.Author;
                DateTime insDateTime = insRevison.DateTime;
            }
            else if (para.IsDeleteRevision)
            {
                EditRevision delRevison = para.DeleteRevision;
                EditRevisionType delType = delRevison.Type;
                string delAuthor = delRevison.Author;
                DateTime delDateTime = delRevison.DateTime;
            }

            foreach (ParagraphBase paraItem in para.ChildObjects)
            {
                if (paraItem.IsInsertRevision)
                {
                    EditRevision insRevison = paraItem.InsertRevision;
                    EditRevisionType insType = insRevison.Type;
                    string insAuthor = insRevison.Author;
                    DateTime insDateTime = insRevison.DateTime;
                }
                else if (paraItem.IsDeleteRevision)
                {
                    EditRevision delRevison = paraItem.DeleteRevision;
                    EditRevisionType delType = delRevison.Type;
                    string delAuthor = delRevison.Author;
                    DateTime delDateTime = delRevison.DateTime;
                }
            }
        }
    }
}

//Get the difference about revisions
DifferRevisions differRevisions = new DifferRevisions(doc1);

doc1.SaveToFile("C:/result.docx", FileFormat.Docx);
Bug SPIREDOC-4025 Fixes the issue that the font was changed after converting Word to Pdf.
Bug SPIREDOC-4505 Fixes the issue that caused extra border after converting Word to PDF.
Bug SPIREDOC-4854 Fixes the issue that the application threw the error "specified algorithm invalid" issue when signing the Word document.
Bug SPIREDOC-5010 Fixes the issue that the image location was moved left after converting Word to PDF.
Bug SPIREDOC-5123 Fixes the issue that the bullet style was changed after converting HTML to Word.
Bug SPIREDOC-5171 Fixes the issue that the table data was incorrect left after converting Word to PDF.
Bug SPIREDOC-5175 Fixes the issue that the application threw the error "System.InvalidOperationException" issue when loading rtf file.
Bug SPIREDOC-5190 Fixes the issue that the application hung when converting Word to PDF.
Bug SPIREDOC-5205 Fixes the issue that caused overlapped content after converting Word to PDF.
Bug SPIREDOC-5224
SPIREDOC-5225
Fixes the issue that caused incorrect format after converting Word to PDF.
Bug SPIREDOC-5244 Fixes the issue that some bookmarks lost after saving Word document.
Bug SPIREDOC-5245 Fixes the issue that after adding Toc field in bookmark, the application threw the error "An object reference is not set to an instance of the object" when executing UpdateTableOfContents() method.
Bug SPIREDOC-5290 Fixes the issue that the application threw the error "System.Collections.Generic.KeyNotFoundException" issue converting HTML to PDF.
Bug SPIREDOC-5291 Fixes the issue that the content was inconsistent after converting HTML to PDF.
Bug SPIREDOC-4223 Fixes the issue that the content was incorrect when filling Html content into the merged fields.
Bug SPIREDOC-4962 Fixes the issue that there are problems with math-equations when opening generated Word document with MS Word.
Bug SPIREDOC-5214 Fixes the issue that the style was missing when cloning document.
Bug SPIREDOC-5324 Fixes the issue that some content was incorrect when converting Word containing Arabic characters to PDF.
Bug SPIREDOC-5349 Fixes the issue that math-equations became pictures when converting Doc to Docx.
Bug SPIREDOC-5367 Fixes the issue that the content of the generated TOC was inconsistent with the outline.
Bug SPIREDOC-4621 Fixes the issue that "-" glyph was missing when converting Word to PDF.
Bug SPIREDOC-4374 Fixes the issue that the content was inconsistent when converting Word to PDF.

Spire.Spreadsheet

Category ID Description
Bug - Fixes the issue that the application threw "System.ArgumentNullException” when loading Excel files.

Spire.XLS

Category ID Description
New Feature SPIREXLS-2515 Supports adjusting the polyline position of the elebow arrow.
GeomertyAdjustValue ad = line.ShapeAdjustValues.AddAdjustValue(GeomertyAdjustValueFormulaType.LiteralValue);
// x is the position of the middle point. When it is less than 0, it is on the left side of the left point. When it is equal to 0, it is the same as the left point. When it is equal to 50, it is in the middle of the graph. When it is 100, it is the same as the right point.
ad.SetFormulaParameter(x);
Bug SPIREXLS-2585 Fixes the issue that the row height was incorrect after invoking the AutoFitRows method.
Bug SPIREXLS-2844 Fixes the issue that the font of the text box text was changed after converting XLS to XLSX.
Bug SPIREXLS-2903 Fixes the issue that the application hung when saving the Excel file.
Bug SPIREXLS-2907 Fixes the issue that the created line chart for pivot table was incorrect.
Bug SPIREXLS-2949 Fixes the issue that the content was incorrect after converting the chart to image.
Bug SPIREXLS-2950 Fixes the issue that the content was incorrect after converting XLS to PDF.
Bug SPIREXLS-2951 Fixes the issue that the obtained trend line equation was incorrect.
Bug SPIREXLS-2952 Fixes the issue that the method WorkBook.GetOleSize returned a wrong value.
Bug SPIREXLS-2957 Fixes the issue that the application threw the error “Object reference not set to an instance of an object” when converting XLS to PDF.
Bug SPIREXLS-2963 Fixes the issue that the calculation result was incorrect after invoking the CalculateAllValue method.
Bug SPIREXLS-2963 Fixes the issue that the content was changed after copying the sheet.
Bug SPIREXLS-2967 Fixes the issue that the application threw the error “The max length of the sheet name is 31“ when converting CSV to PDF.
Bug SPIREXLS-2980 Fixes the issue that the position of the inserted line was incorrect.
Bug SPIREXLS-2980 Fixes the issue that an error prompted when opening the result file after loading and saving the document twice.

Spire.PDF

Category ID Description
Optimization SPIREPDF-837 Supports embedding all used fonts in an existing PDF.
New Feature SPIREPDF-3736 Supports adding page label
//When PDF file doesn't have page labels
PdfDocument doc = new PdfDocument(inputFile);
doc.PageLabels = new PdfPageLabels();
doc.PageLabels.AddRange(0, PdfPageLabels.Decimal_Arabic_Numerals_Style, "label ");
doc.SaveToFile(outputPDF);

//When PDF file has page labels
PdfDocument doc = new PdfDocument(inputFile);
PdfPageLabels label = doc.PageLabels;
label.AddRange(2, PdfPageLabels.Decimal_Arabic_Numerals_Style, "new label ");
doc.SaveToFile(outputPDF);
New Feature SPIREPDF-993
SPIREPDF-3652
Supports converting PDF to PDFX1A.
PdfStandardsConverter converter = new PdfStandardsConverter("in.pdf");
converter.ToPdfX1A2001("out.pdf");
New Feature SPIREPDF-3284
SPIREPDF-3649
Supports customizing text/image's locations when adding digital signatures.
signature.ConfigureCustomGraphics(DrawGraphics);
private void DrawGraphics(PdfCanvas g)
{
g.DrawString("Signed by:Tom", new PdfFont(PdfFontFamily.Helvetica, 12f), PdfBrushes.Red, new Rectangle(0, 0, 120, 20));
string inputFile = "C:/image.png";
PdfImage img = PdfImage.FromFile(inputFile);
g.DrawImage(img, 0, 60, 150, 50);
}
New Feature SPIREPDF-2609
SPIREPDF-2804
SPIREPDF-3351
SPIREPDF-3527
SPIREPDF-3775
Supports digitally signing the PDF through external services.
  void Sign()
        {
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(inputPath);
            //Load the certificate
            X509Certificate2 cert = new X509Certificate2(certPath, passwd);
            CustomPKCS7SignatureFormatter customPKCS7SignatureFormatter = new CustomPKCS7SignatureFormatter(cert);
            PdfSignature signature = new PdfSignature(doc, doc.Pages[0], customPKCS7SignatureFormatter, "signature0");
            signature.Bounds = new RectangleF(new PointF(90, 550), new SizeF(270, 90));
            //Set the dispay mode of graphics, if not set any, the default one will be applied
            signature.GraphicsMode = GraphicMode.SignDetail;
            signature.NameLabel = "Signer:";
            signature.Name = "gary";
            signature.ContactInfoLabel = "ContactInfo:";
            signature.DateLabel = "Date:";
            signature.Date = DateTime.Now;
            signature.LocationInfoLabel = "Location:";
            signature.LocationInfo = "Chengdu";
            signature.ReasonLabel = "Reason: ";
            signature.Reason = "The certificate of this document";
            signature.DistinguishedNameLabel = "DN: ";
            signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges;
            signature.SignDetailsFont = new PdfFont(PdfFontFamily.TimesRoman, 10f);
            signature.SignNameFont = new PdfFont(PdfFontFamily.Courier, 15);
            signature.SignImageLayout = SignImageLayout.None;
            //Save pdf file.
            doc.SaveToFile(outputPath, Spire.Pdf.FileFormat.PDF);
        }

        class CustomPKCS7SignatureFormatter : IPdfSignatureFormatter
        {
            /// 
            /// If encapsulate is true, a copy of the message will be included in the signature.
            /// 
            private bool m_encapsulate = true;

            /// 
            /// The signing certificate.
            /// 
            private X509Certificate2 m_certificate = null;

            public Dictionary m_parameters = new Dictionary();
            /// 
            /// Parameters for the encoding of the signature.
            /// 1.Key:Filter,String
            /// Required
            /// The name of the preferred signature handler to use when validating this signature.
            /// 2.SubFilter,String
            /// Required
            /// A name that describes the encoding of the signature value.
            /// PDF 1.6 defines the following values for public-key cryptographic signatures: adbe.x509.rsa_sha1, adbe.pkcs7.detached, and adbe.pkcs7.sha1
            /// 3.Cert,X509Certificate2
            /// Required when SubFilter is adbe.x509.rsa_sha1
            /// 
            public Dictionary Parameters
            {
                get

                { return m_parameters; }
            }

            /// 
            /// Construct a new instance.
            /// 
            /// The signing certificate.
            /// 
            /// If encapsulate is true, a copy of the message will be included in the signature.
            /// 
            public CustomPKCS7SignatureFormatter(X509Certificate2 certificate)
            {
                if (null == certificate)

                { throw new ArgumentNullException("certificate"); }
                m_certificate = certificate;
                Parameters.Add("Filter", "Adobe.PPKMS");
                Parameters.Add("SubFilter", m_encapsulate ? "adbe.pkcs7.sha1" : "adbe.pkcs7.detached");
            }

            /// 
            /// Sign.
            /// 
            /// The data that contains signature content.
            /// The signature
            public byte[] Sign(byte[] content)
            {
                CmsSigner cmsSigner = new CmsSigner(m_certificate);
                SHA1 sha1 = SHA1.Create();
                SignedCms signedCms = new SignedCms(new ContentInfo(m_encapsulate ? sha1.ComputeHash(content) : content), !m_encapsulate);
                signedCms.ComputeSignature(cmsSigner, true);
                byte[] result = signedCms.Encode();
                return result;
            }
        }
New Feature SPIREPDF-3724 Support setting the file fields for PDF Portfolios and sorting the files.
string[] files = Directory.GetFiles(@"files");
string inputFile = @"input.pdf";
string outputFile = @"output.pdf";
using (PdfDocument doc = new PdfDocument(inputFile))
{
    //Add the custom field
    doc.Collection.AddCustomField("No", "No", Spire.Pdf.Collections.CustomFieldType.NumberField);
    doc.Collection.AddFileRelatedField("FileName", "FileName", Spire.Pdf.Collections.FileRelatedFieldType.FileName);
    doc.Collection.AddFileRelatedField("Desc", "Desc", Spire.Pdf.Collections.FileRelatedFieldType.Desc);
    doc.Collection.AddFileRelatedField("CreateDate", "CreateDate", Spire.Pdf.Collections.FileRelatedFieldType.CreationDate);
    doc.Collection.AddFileRelatedField("ModDate", "ModDate", Spire.Pdf.Collections.FileRelatedFieldType.ModDate);
    doc.Collection.AddFileRelatedField("FileSize", "FileSize", Spire.Pdf.Collections.FileRelatedFieldType.Size);
    doc.Collection.AddCustomField("FileType", "FileType", Spire.Pdf.Collections.CustomFieldType.TextField);
    doc.Collection.AddCustomField("FileDate", "FileDate", Spire.Pdf.Collections.CustomFieldType.DateField);

    //Sort the file
    doc.Collection.Sort(new string[] { "No", "fileName", "Desc", "CreateDate", "ModDate", "FileSize", "FileType", "FileDate" }, new bool[] { false, true, true, true, true, true, true, true });
    for (int i = 0; i < files.Length; i++)
    {
        PdfAttachment attachment = new PdfAttachment(files[i]);
        doc.Collection.AddAttachment(attachment);
    }
    int n = 1;
    //Set the field value
    foreach (PdfAttachment att in doc.Collection.AssociatedFiles)
    {
        att.SetFieldValue("No", n);
        att.Description = n + "description";
        att.SetFieldValue("FileDate", DateTime.Today);
        att.SetFieldValue("FileType", n + "file");
        n++;
    }
    doc.SaveToFile(outputFile, FileFormat.PDF);
    doc.Dispose();
}
New Feature SPIREPDF-3786 Supports setting the attachment relationship when adding attachments.
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(inputPath);
PdfAttachment attachment = new PdfAttachment(attachmentPath);
doc.Attachments.Add(attachment,doc,Spire.Pdf.General.PdfAttachmentRelationship.Alternative);
doc.SaveToFile(outputPath);
New Feature SPIREPDF-3867 Supports finding text in a specific area.
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile, FileFormat.PDF);
RectangleF rctg = new RectangleF(0, 0, 200, 100);
PdfTextFindCollection findCollection = pdf.Pages[0].FindText(rctg, "DEPOSIT", TextFindParameter.WholeWord);
PdfTextFindCollection findCollectionOut = pdf.Pages[0].FindText(rctg, "agreement", TextFindParameter.WholeWord);
foreach (PdfTextFind find in findCollection.Finds)
{ find.ApplyHighLight(Color.Green); }
foreach (PdfTextFind findOut in findCollectionOut.Finds)
{ findOut.ApplyHighLight(Color.Yellow); }
pdf.SaveToFile(outputFile, FileFormat.PDF);
Bug SPIREPDF-844 Fixes the issue that the signed PDF could not be opened with foxit reader.
Bug SPIREPDF-1620 Fixes the issue that the application threw "out of memory" exception when retrieving images.
Bug SPIREPDF-2681 Fixes the issue that the content was incorrect when converting PDF to Image.
Bug SPIREPDF-3640 Fixes the issue that the annotations were missing when converting PDF to Tiff.
Bug SPIREPDF-3759 Fixes the issue that the images were missing when printing PDF.
Bug SPIREPDF-3776 Fixes the issue that content overlapped when adding superscript and parenthesis in PdfGrid cell.
Bug SPIREPDF-3510 Fixes the issue that the content was discrepant when converting PDF to Excel.
Bug SPIREPDF-3634 Fixes the issue that the style was discrepant when converting PDF to Excel.
Bug SPIREPDF-3658 Fixes the issue that the nested grids were overlapped.
Bug SPIREPDF-3809 Fixes the issue that only one digital signature could be signed after encrypting PDF.
Bug SPIREPDF-3817 Fixes the issue that the name of the added attachment obtained with the PDFdetach tool was incorrect
Bug SPIREPDF-3822 Fixes the issue that the content with two different font sizes was overlapped in a Grid cell whe setting right-aligned.
Bug SPIREPDF-3824 Fixes the issue that the application threw NullReferenceException when converting PDF to Images.
Bug SPIREPDF-3828 Fixes the issue that the application threw NullReferenceException when getting PDF page.
Bug SPIREPDF-3829 Fixes the issue that the content was garbled when printing PDF.
Bug SPIREPDF-3834 Fixes the issue that the superscripts and subscripts didn't work when setting the StringFormat of a grid cell.
Bug SPIREPDF-3839 Fixes the issue that vertical center style did not work after reducing the row height of a grid cell.
Bug SPIREPDF-3706 Fixes the issue that the generated file did not conform to the standard of PDF/A-3B after converting PDF with attachments to PDF/A-3B.
Bug SPIREPDF-3719 Fixes the issue that the generated files did not conform to the standard of PDF/A after converting PDF with actions to PDF/A.
Bug SPIREPDF-3802 Fixes the issue that the application hung when getting the bookmarks.
Bug SPIREPDF-3825 Adjusts the initialization method of PdfTrueTypeFont class for .NET Standard APIs
Bug SPIREPDF-3837 Fixes the issue that the annotations couldn't be removed.
Bug SPIREPDF-3852 Fixes the issue that the character spacing were incorrect after adding subscripts and subscripts.
Bug SPIREPDF-3856 Fixes the issue that the application threw the error "NullReferenceException" when finding the text.
Bug SPIREPDF-3870 Fixes the issue that not all matches were found when finding text.