Syncfusion is happy to announce that our 2019 Volume 2 beta release has been rolled out. In this blog, we will give you a quick overview of the new features and enhancements introduced in our file-format libraries. Syncfusion file-format libraries provide .NET libraries to create, read, write, and convert PDF, Excel, Word, and PowerPoint files in .NET Framework, .NET Core, UWP, and Xamarin applications without Microsoft Office or Adobe dependencies.
Let’s dive into the details about the new features and enhancements.
PDF library
Add comments to PDF
During the review process, comments are useful to add a note about contents marked by annotations.
Now, you can add comments to markup annotations such as line, square, circle, polygon, polyline, highlight, underline, strikethrough, rubber stamp, ink, and so on using Syncfusion’s PDF library. It also provides a feature for replying to primary comments and setting a review status.
The following code example illustrates how to add comments, reply to them, and set the review status.
//Load the existing PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Load the existing PDF page PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; //Get the first annotation of the page. PdfLoadedTextMarkupAnnotation loadedTextMarkupAnnotation = loadedPage.Annotations[0] as PdfLoadedTextMarkupAnnotation; //Create a new comment PdfPopupAnnotation userQuery = new PdfPopupAnnotation(); userQuery.Author = "John"; userQuery.Text = "Can you please change South Asian to Asian?"; userQuery.ModifiedDate = DateTime.Now; //Add comment to the annotation loadedTextMarkupAnnotation.Comments.Add(userQuery); //Creates a new comment PdfPopupAnnotation userAnswer = new PdfPopupAnnotation(); userAnswer.Author = "Smith"; userAnswer.Text = "South Asian has changed as Asian"; userAnswer.ModifiedDate = DateTime.Now; //Add comment to the annotation loadedTextMarkupAnnotation.Comments.Add(userAnswer); //Creates a new review PdfPopupAnnotation userAnswerReview = new PdfPopupAnnotation(); userAnswerReview.Author = "Smith"; userAnswerReview.State = PdfAnnotationState.Completed; userAnswerReview.StateModel = PdfAnnotationStateModel.Review; userAnswerReview.ModifiedDate = DateTime.Now; //Add review to the comment userAnswer.ReviewHistory.Add(userAnswerReview); //Creates a new review PdfPopupAnnotation userAnswerReviewJohn = new PdfPopupAnnotation(); userAnswerReviewJohn.Author = "John"; userAnswerReviewJohn.State = PdfAnnotationState.Accepted; userAnswerReviewJohn.StateModel = PdfAnnotationStateModel.Review; userAnswerReviewJohn.ModifiedDate = DateTime.Now; //Add review to the comment userAnswer.ReviewHistory.Add(userAnswerReviewJohn); //Save and close the PDF document loadedDocument.Save("AnnotationCommentAndReview.pdf"); loadedDocument.Close(true);
Output PDF File with Comments
For more details about annotations and comments, check out our documentation: Working with PDF Annotations.
TIFF to PDF in .NET Core
The Syncfusion PDF library already supported TIFF-to-PDF conversion in .NET Framework platforms. Now, you can convert multi-frame TIFF images to PDF documents in .NET Core.
The following code example shows how to convert TIFF to PDF.
//Create a new PDF document PdfDocument document = new PdfDocument(); //Set margin to the page document.PageSettings.Margins.All = 0; //Load TIFF image to stream FileStream imageFileStream = new FileStream("image.tiff", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //Load multi-frame TIFF image PdfBitmap tiffImage = new PdfBitmap(imageFileStream); //Get the frame count int frameCount = tiffImage.FrameCount; //Access each frame and draw onto the page for (int i = 0; i < frameCount; i++) { //Add new page for each frame PdfPage page = document.Pages.Add(); //Get page graphics PdfGraphics graphics = page.Graphics; //Set active frame tiffImage.ActiveFrame = i; //Draw TIFF image onto page graphics.DrawImage(tiffImage, 0, 0, page.GetClientSize().Width, page.GetClientSize().Height); } //Save PDF document MemoryStream stream = new MemoryStream(); document.Save(stream); //Close the PDF document document.Close(true);
Output PDF File Created from a Multi-frame TIFF Image
PDF 2.0
Support has been added to create a PDF document based on the PDF specification version 2.0 (ISO32000-2). You can specify the PDF version as required. When setting the PDF version as 2.0, deprecated elements will not be preserved in the resultant document.
Let’s see the code example of how to specify the PDF version as 2.0.
//Create a new PDF document PdfDocument document = new PdfDocument(); //Set the PDF version document.FileStructure.Version = PdfVersion.Version2_0; //Add a new PDF page PdfPage page = document.Pages.Add(); //Create new PdfStandard font PdfStandardFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 16); //Draw string to the PDF document page page.Graphics.DrawString("Hello World!...", font, PdfBrushes.Black, new System.Drawing.PointF(0, 0)); //Save and close the PDF document document.Save("PDFVersion2_0.pdf"); document.Close(true);
Output PDF File Generated with PDF Version as 2.0
Excel library
Excel table with parameter query
The creation of Excel tables by importing data from SQL Server through Excel data connections is supported. Also, queries can be modified at runtime with the help of parameters.
The Syncfusion Excel (XlsIO) library provides the option to set parameter values. The parameters can be set for a query either through a prompt event, as a constant, or as an Excel range.
Let’s consider a situation where you have an Excel template that contains a table with an external data connection as follows:
Excel Template with External Connection
The following code example illustrates how to set the parameter through a prompt event by accessing an existing Excel table with connections.
using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; //Load existing Excel template document with external connection IWorkbook workbook = application.Workbooks.Open("../../Data/Template.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; //Acquire the query table from the Excel table from the template document QueryTableImpl queryTable = worksheet.ListObjects[0].QueryTable; //Add a parameter IParameter parameter1 = queryTable.Parameters.Add("parameter1", ExcelParameterDataType.ParamTypeChar); //Set PROMPT parameter parameter1.SetParam(ExcelParameterType.Prompt, "30"); parameter1.Prompt += new PromptEventHandler(SetParameter); //Update Excel query to filter data from various parameter types string query = "select * from Employee_Details where Emp_Age > ?;"; queryTable.CommandText = query; //Refresh Excel table to filter data while loading Excel document if (this.refreshTable.Checked) worksheet.ListObjects[0].Refresh(); workbook.SaveAs("Output.xlsx"); } private void SetParameter(object sender, PromptEventArgs args) { args.Value = 30; }
Output File with Employee Details Filtered by Emp_Age > 30
For more information about creating external data connections and setting parameters, refer to our documentation page on external data connections.
Excel chart enhancements
Certain Excel charts provide additional features that help users visualize data more easily. Drop lines are one such feature provided in Microsoft Excel. Now, XlsIO supports the drop line feature in Excel area and line charts, which helps viewers determine the data points relative to the horizontal axis.
The following code shows how to apply drop lines in an Excel line chart.
using (ExcelEngine engine = new ExcelEngine()) { IApplication application = engine.Excel; IWorkbook workbook = application.Workbooks.Open("HighLowLinesSample.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; IChartShape chart = worksheet.Charts[0]; IChartSerie chartSerie = chart.Series[0]; chart.ChartTitle = "Drop Lines"; //Set HasDropLines property to true. chartSerie.SerieFormat.CommonSerieOptions.HasDropLines = true; //Apply formats to DropLines. chartSerie.SerieFormat.CommonSerieOptions.DropLines.LineColor = Color.Red; chartSerie.SerieFormat.CommonSerieOptions.DropLines.LineWeight = ExcelChartLineWeight.Hairline; chartSerie.SerieFormat.CommonSerieOptions.DropLines.LinePattern = ExcelChartLinePattern.Dot; workbook.SaveAs("DropLines.xlsx"); workbook.Close(); }
Excel Line Chart with Drop Lines
Trace precedents and dependents enhancements
Precedent cells are cells that are referred to by a formula in another cell. Dependent cells contain formulas that refer to other cells. XlsIO allows users to trace the relationship between cells and formulas in Excel workbooks, and returns the list of cells or ranges that are precedent and dependent.
In addition, XlsIO now supports getting the direct precedents and direct dependents of a worksheet or workbook. These methods return the direct precedent and dependent cells by excluding the inner precedent and dependent cells.
The GetDirectDependents() and GetDirectPrecedents() methods achieve this feature.
The following code shows how to get direct precedents.
using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; IWorkbook workbook = application.Workbooks.Open("FormulaExcel.xlsx"); IWorksheet sheet = workbook.Worksheets[0]; //Get direct precedent cells from the worksheet IRange[] results1 = sheet["A1"].GetDirectPrecedents(); //Get direct precedent cells from the workbook IRange[] results2 = sheet["A1"].GetDirectPrecedents(true); string fileName = "DirectPrecedents.xlsx"; workbook.SaveAs(fileName); }
The following code shows how to get direct dependents.
using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; IWorkbook workbook = application.Workbooks.Open("FormulaExcel.xlsx"); IWorksheet sheet = workbook.Worksheets[0]; //Get direct dependent cells from the worksheet IRange[] results1 = sheet["A1"].GetDirectDependents(); //Get direct dependent cells from the workbook IRange[] results2 = sheet["A1"].GetDirectDependents(true); string fileName = "DirectDependents.xlsx"; workbook.SaveAs(fileName); }
To learn more details about precedents and dependents, check out our documentation page, Get Precedent and Dependent Cells or Range.
Word library
Mail merge enhancements
The Syncfusion’s Word (DocIO) library now provides the following features in mail merge:
- Event to customize clearing unmerged fields during mail merge.
- Event to customize removing unmerged groups during mail merge.
- Option to access the new instance (WPicture or WTextRange) replaced during mail merge.
- Ability to execute mail merge using ADO.NET objects in ASP.NET Core and Xamarin platforms.
For more information and code examples about mail merge, refer to our documentation on working with mail merge.
Group shape
Now, you can create group shapes in Word documents (DOCX) and preserve them during DOCX-to-PDF conversion.
The following code example illustrates creating group shapes in a Word document (DOCX) and converting it to PDF.
Group Shapes in Converted PDF Document
For more information about shapes, refer to our documentation, working with shapes.
Right-to-left text rendering improvements
Right-to-left (RTL) text rendering in Word-to-PDF and Word-to-image conversions has been improved significantly.
Improved RTL Text Support in Word-to-PDF Conversion
PowerPoint library
Write protection
Now, the Syncfusion PowerPoint (Presentation) library allows enabling write protection for PowerPoint presentations. With this feature, you can set write protection for a PowerPoint presentation and remove protection from an existing write-protected presentation.
The following code example illustrates how to set write protection for a PowerPoint file.
//Opens the PowerPoint presentation IPresentation presentation = Presentation.Open("Input.pptx"); //Sets the write protection for presentation instance presentation.SetWriteProtection("Password"); //Saves the write-protected PowerPoint presentation presentation.Save("WriteProtection.pptx"); //Closes the presentation instance presentation.Close();
Write-Protected PowerPoint Presentation
To learn more about the security features of our PowerPoint library, refer to this documentation page on protecting, encrypting, and decrypting PowerPoint files.
Try it out
We believe you will love these new features and enhancements included in the 2019 Volume 2 release. Are you interested in trying them out? You can download the latest beta version from this page, or you can get our NuGet packages from nuget.org.
To get hands-on experience with the file-format libraries, check out the samples in the following GitHub locations,
If you don’t have a Syncfusion license but would like to try out these new features, you can sign up for a free 30-day trial.
If you are new to Syncfusion’s file-format libraries, we highly recommend that you follow our user guide. To get started with a specific file format, follow these links:
- Create PDF file in C# without Adobe
- Generate Excel file in C# without Microsoft Office
- Create Word file in C# without Microsoft Office
- Generate PowerPoint file in C# without Microsoft Office
If you have any questions or require clarifications about these features, please let us know in the comments below. You can also contact us through our support forum, Direct-Trac, or feedback portal. We are happy to assist you!
Comments (1)
nice well explained
Comments are closed.