2019 Volume 1: Syncfusion File Format Libraries | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (174).NET Core  (29).NET MAUI  (207)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (217)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (917)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (148)Chart  (131)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (629)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (507)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (593)What's new  (332)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
whats-new-in-syncfusion-file-formats

2019 Volume 1: Syncfusion File Format Libraries

Syncfusion 2019 Volume 1 (version 17.1) release introduces exciting new features and improvements aimed at making document processing easier with its file-format libraries. Syncfusion’s file format libraries allow users to create, read, edit, and convert ExcelPDFWord, and PowerPoint files in .NET applications without the need of Microsoft Office or Adobe dependencies.

In this blog, we will describe in detail the newly added features and enhancements.

PDF Library

ZUGFeRD PDF invoice

ZUGFeRD is an electronic billing data format for exchanging invoices. It consists of two parts: a pictorial or textual representation of the invoice for human reading and machine-readable structured data. Therefore, it helps to automate the reading and processing of invoices. The machine-readable structured data in XML format is attached to the PDF/A-3 document. The Syncfusion PDF Library now supports creating ZUGFeRD PDF invoice documents.

The following code example illustrates how to create a ZUGFeRD PDF invoice using Syncfusion PDF Library.

//Create ZUGfeRD invoice PDF
PdfDocument document = new PdfDocument(PdfConformanceLevel.Pdf_A3B);
document.ZugferdConformanceLevel = ZugferdConformanceLevel.Basic;
//Creates an PDF attachment.
//Important Note: XML name must be as “ZUGFeRD-invoice.xml”
PdfAttachment attachment = new PdfAttachment("ZUGFeRD-invoice.xml","../../Data/ZUGFeRD-invoice.xml");
attachment.Relationship = PdfAttachmentRelationship.Alternative;
attachment.ModificationDate = DateTime.Now;
attachment.Description = "ZUGFeRD-invoice";
attachment.MimeType = "application/xml";
document.Attachments.Add(attachment);
// save and close the document.
document.Save("Zugferd.pdf");
document.Close(true);

PDF ZUGFeRD invoice using C#PDF ZUGFeRD invoice created via Syncfusion PDF Library

For more information on creating ZUGFeRD PDF invoices, please refer to our documentation page—Generating ZUGFeRD invoice.

PDF/A-2b and PDF/A-3b conformance

Syncfusion PDF Library already supports creating PDF/A-1b-conforming documents. In addition, you can create PDF document from scratch with conformance of PDF/A-2b (ISO 19005-2) and PDF/A-3b (ISO 19005-3), now.

  • PDF/A-2b represents minimal compliance to ensure that the rendered visual appearance of the file is preservable long term.
  • PDF/A-3b represents PDF/A-2b documents with file attachments.

 

PDF/A-2B conformance document created using Syncfusion PDF libraryPDF/A-2b-conforming document created using Syncfusion PDF Library

PDF/A-3B conformance document created using Syncfusion PDF libraryPDF/A-3b-conforming document created using Syncfusion PDF Library

To learn more about PDF conformance, please refer to our documentation page—PDF Conformance.

Create and fill XFA form fields in .NET Core

Syncfusion PDF Library already supports creating and filling XFA form fields in the .NET Framework. Now, that support extends to the .NET core platform, as well. Using this, you can create rich-looking XFA forms and fill any XFA documents in .NET Core and Xamarin applications.

The following code example shows how to fill XFA form fields in an existing PDF document.

//Load the PDF file with XFA form as stream.
FileStream file1 = new FileStream(dataPath + "xfaTemplate.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
PdfLoadedXfaDocument ldoc = new PdfLoadedXfaDocument(inputPdfFileStream);
 
//Loaded the existing XFA form.
PdfLoadedXfaForm lform = ldoc.XfaForm;
 
//Fill the XFA form fields.
 (((lform.Fields["subform1[0]"] as PdfLoadedXfaForm).Fields["subform3[0]"] as PdfLoadedXfaForm).Fields["title[0]"] as PdfLoadedXfaComboBoxField).SelectedIndex = 0;
 (((lform.Fields["subform1[0]"] as PdfLoadedXfaForm).Fields["subform3[0]"] as PdfLoadedXfaForm).Fields["fn[0]"] as PdfLoadedXfaTextBoxField).Text = "Simons";
 (((lform.Fields["subform1[0]"] as PdfLoadedXfaForm).Fields["subform3[0]"] as PdfLoadedXfaForm).Fields["ln[0]"] as PdfLoadedXfaTextBoxField).Text = "Bistro";
 
MemoryStream ms = new MemoryStream();
 
//save and close the document.
ldoc.Save(ms);
ldoc.Close();

XFA form fields filled using Syncfusion PDF libraryXFA form fields filled using Syncfusion PDF Library

To find further information about XFA creation and filling, please check our documentation page—Working with XFA.

Retrieve annotation review status and comment

Syncfusion PDF Library let’s you retrieve annotation review status and comments from the reviewed PDF document.

//Load the existing PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf");
 
//Get the existing PDF page.
PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage;
 
//Get the annotation.
PdfLoadedTextMarkupAnnotation loadedMarkup = loadedPage.Annotations[0] as PdfLoadedTextMarkupAnnotation;
 
//Get the review history collection for the annotation.
PdfLoadedPopupAnnotationCollection reviewCollection = loadedMarkup.ReviewHistory;
 
//Get the annotation state.
PdfAnnotationState state = reviewCollection[0].State;
 
//Get the annotation state model.
PdfAnnotationStateModel model = reviewCollection[0].StateModel;
 
//Get the comments of the annotation.
PdfLoadedPopupAnnotationCollection commentsCollection = loadedMarkup.Comments;
 
//Get the review history of the comment.
PdfLoadedPopupAnnotationCollection reviewCollection1 = commentsCollection[0].ReviewHistory;
 
//Close the PDF document.
loadedDocument.Close(true);

Import and export annotations to XFDF/FDF format

FDF (Forms Data Format)/XFDF (XML based FDF) is a format for representing forms and annotations data. Annotations and their comments can be exported or imported from PDF documents. It will be easier for users to manipulate the annotations in a separate file or format. We have added support for importing and exporting annotation data to XFDF/FDF format.

The following is a code example for exporting annotations to FDF and XFDF format.

//Load an existing PDF document.
PdfLoadedDocument document = new PdfLoadedDocument(@"..\..\Data\Annotations.pdf");
 
//Export annotation to FDF format.
document.ExportAnnotations(@"Annotations.fdf", AnnotationDataFormat.Fdf);
 
//Close the PDF document.
document.Close(true);

The following is a code example for importing annotations to FDF format data:

//Load an existing PDF document.
PdfLoadedDocument document = new PdfLoadedDocument(@"EmptyTemplate.pdf");
 
//Import annotation data from FDF/XFDF file.
document.ImportAnnotations(@"Annotations.fdf", AnnotationDataFormat.Fdf);
 
//Save and close the document.
document.Save(@"Annotations.pdf");
document.Close(true);

Import and export annotation as FDF or XFDF with Syncfusion PDF libraryImport and export annotations as FDF or XFDF with Syncfusion PDF Library

Excel Library

Chart to image in .NET Core and Xamarin

The Syncfusion Excel Library (XlsIO) now supports converting an Excel chart to an image in .NET Core and Xamarin applications. All 2D and 3D charts can be converted, along with their elements such as chart titles, axis titles, data labels, and legends. The charts can be converted to JPEG and PNG.

The following C# example shows how to convert an Excel chart to an image.

//Create Excel engine
using (ExcelEngine excelEngine = new ExcelEngine())
{
    //Instantiate the application and Excel renderer objects.
    IApplication application = excelEngine.Excel;
    application.XlsIORenderer = new XlsIORenderer();
    application.XlsIORenderer.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png;
    
    //Open an Excel file with chart.
    IWorkbook workbook = application.Workbooks.Open(File.OpenRead("Sample.xlsx"));
    IWorksheet worksheet = workbook.Worksheets[0];
    IChart chart = worksheet.Charts[0];

    //Create the memory stream for saving chart image.
    Stream stream = new FileStream("chart.png", FileMode.Create, FileAccess.ReadWrite);
    //Convert chart to image.
    chart.SaveAsImage(stream);
    stream.Dispose();
}

Excel Chart to image conversion with Syncfusion Excel libraryExcel Chart-to-image conversion with Syncfusion Excel library

Excel to PDF enhancements

The Syncfusion Excel (XlsIO) Library now provides the following improvements in Excel-to-PDF conversion:

  • All the 2D and 3D charts are preserved in the PDF document with .NET Core and Xamarin applications.
  • Convert Excel files to PDF with the PDF-A1B conformance standard in all the .NET applications.

The following code example illustrates how to convert an Excel file to PDF

using (ExcelEngine engine = new ExcelEngine())
{
    IApplication application = engine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2016;

    //Initialize the Excel renderer class to convert Excel charts with PDF conversion.
    XlsIORenderer renderer = new XlsIORenderer();

    Stream fileStream = File.OpenRead("Sample.xlsx");
    IWorkbook workbook = application.Workbooks.Open(fileStream);

    Stream stream = File.Create("output.pdf");
    PdfDocument pdf = renderer.ConvertToPDF(workbook);

    pdf.Save(stream);
    pdf.Close();

    stream.Dispose();
}

To know more about Excel-to-PDF conversion, please refer to our documentation pages—Excel-to-PDF conversion and convert Excel-to-PDF with conformance level.

Custom table styles

Syncfusion Excel Library has the support to apply formatting to Excel tables using built-in table styles. From this release, you can create your own table style and apply it to Excel tables, too.

The following code example illustrates how to create a new table style and apply it.

//Create Excel engine instance.
using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;

    //Open an existing Excel file with data.
    IWorkbook workbook = application.Workbooks.Open(File.Open("Sample.xlsx", FileMode.Open));
    IWorksheet worksheet = workbook.Worksheets[0];

    //Create style for table number format.
    IStyle style = workbook.Styles.Add("CurrencyFormat");
    style.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* \" - \"??_);_(@_)";
    worksheet["B2:E8"].CellStyleName = "CurrencyFormat";

    //Create table instance.
    IListObject table = worksheet.ListObjects.Create("Table1", worksheet["A1:E7"]);
                
    //Create and apply custom table style.
    ITableStyles tableStyles = workbook.TableStyles;
    ITableStyle tableStyle = tableStyles.Add("Table Style 1");
    ITableStyleElements tableStyleElements = tableStyle.TableStyleElements;
    ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.SecondColumnStripe);
    tableStyleElement.BackColorRGB = Color.FromArgb(217, 225, 242);

    ITableStyleElement tableStyleElement1 = tableStyleElements.Add(ExcelTableStyleElementType.FirstColumn);
    tableStyleElement1.FontColorRGB = Color.FromArgb(128, 128, 128);

    ITableStyleElement tableStyleElement2 = tableStyleElements.Add(ExcelTableStyleElementType.HeaderRow);
    tableStyleElement2.FontColor = ExcelKnownColors.White;
    tableStyleElement2.BackColorRGB = Color.FromArgb(0, 112, 192);

    ITableStyleElement tableStyleElement3 = tableStyleElements.Add(ExcelTableStyleElementType.TotalRow);
    tableStyleElement3.BackColorRGB = Color.FromArgb(0, 112, 192);
    tableStyleElement3.FontColor = ExcelKnownColors.White;

    table.TableStyleName = tableStyle.Name;

    
    table.ShowTotals = true;
    table.ShowFirstColumn = true;
    table.ShowTableStyleColumnStripes = true;
    table.ShowTableStyleRowStripes = true;
    table.Columns[0].TotalsRowLabel = "Total";
    table.Columns[1].TotalsCalculation = ExcelTotalsCalculation.Sum;
    table.Columns[2].TotalsCalculation = ExcelTotalsCalculation.Sum;
    table.Columns[3].TotalsCalculation = ExcelTotalsCalculation.Sum;
    table.Columns[4].TotalsCalculation = ExcelTotalsCalculation.Sum;

    //Save the workbook.
    workbook.SaveAs("CustomTableStyle.xlsx");
}

Applying custom table style to Excel table with Syncfusion Excel libraryApplied custom table style to Excel table with Syncfusion Excel Library

Conditional formatting enhancement

Now, Syncfusion Excel Library supports applying formatting for unique and duplicate values in Excel worksheets through conditional formatting. This conditional formatting enhancement is supported with Excel-to-PDF conversion, as well.

using (ExcelEngine engine = new ExcelEngine())
 {
     IApplication application = engine.Excel;
     IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
     IWorksheet worksheet = workbook.Worksheets[0];
 
     //conditional format to choose single range.
     IConditionalFormats conditionformat1 =   
     worksheet.Range["C5:C50"].ConditionalFormats;
     IConditionalFormat condition1 = conditionformat1.AddCondition();
     condition1.FormatType = ExcelCFType. Duplicate;
     condition1.BackColor = ExcelKnownColors.Light_pink;

     //Save as file in xlsx format
     workbook.SaveAs("xml.xlsx");   
 }

Highlighted duplicate values with conditional format support in Syncfusion Excel libraryHighlighted duplicate values using conditional formatting support in Syncfusion Excel Library

Word Library

Word-to-PDF enhancements in .NET Core and Xamarin platforms

The Syncfusion Word (DocIO) library now provides the following improvements in Word-to-PDF conversion with .NET Core and Xamarin platforms:

  • Preservation of 2D and 3D charts.
  • Improvements in text-size calculation to paginate Word documents properly.
  • Improvements in font retrieval and substitution.

The following code example illustrates how to convert a Word document to PDF with charts in ASP.NET Core and Xamarin platforms.

FileStream fileStream = new FileStream("Template.docx", FileMode.Open);

//Loads an existing Word document.
WordDocument wordDocument = new WordDocument(fileStream, FormatType.Docx);

//Instantiates DocIORenderer instance for Word-to-PDF conversion.
DocIORenderer renderer = new DocIORenderer();

//Set the chart-rendering options to export chart as PNG format image.
renderer.Settings.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png;

//Converts Word document into PDF document.
PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument);

//Closes the instance of Word document object.
wordDocument.Close();

//Releases the resources occupied by DocIORenderer instance.
renderer.Dispose();

//Saves the PDF file.
MemoryStream outputStream = new MemoryStream();
pdfDocument.Save(outputStream);

//Closes the instance of PDF document object.
pdfDocument.Close();

"<yoastmark

Chart to image in .NET Core and Xamarin

The charts in a Word document can be converted to JPEG or PNG images in .NET Core and Xamarin applications. All 2D and 3D charts can be converted along with their elements.

FileStream fileStream = new FileStream("Template.docx", FileMode.Open); 
 
//Loads an existing Word document.
WordDocument wordDocument = new WordDocument(fileStream, FormatType.Docx); 
 
//Instantiates DocIORenderer instance for Word-to-PDF conversion.
DocIORenderer renderer = new DocIORenderer(); 
 
//Sets chart-rendering options to export chart as PNG format image.
renderer.Settings.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png; 
 
//Converts chart to image and saves to stream. 
MemoryStream outputStream = new MemoryStream();
renderer.SaveChartAsImage((wordDocument.LastParagraph.ChildEntities[0] as WChart).OfficeChart, outputStream); 

//Closes the instance of Word document object. 
wordDocument.Close(); 
 
//Releases the resources occupied by DocIORenderer instance. 
renderer.Dispose();

Convert Chart from Word document to image using Syncfusion Word libraryConvert chart from Word document to an image using Syncfusion Word Library

PowerPoint Library

Convert PowerPoint to PDF in .NET Core and Xamarin

The Syncfusion PowerPoint Library now supports the conversion of PowerPoint to PDF in .NET Core and Xamarin platforms with the following customization options:

  • Specify the number of slides per PDF page with the ‘Handouts’ option.
  • Convert slides with a notes pages to PDF.
  • Embed fonts in a PowerPoint file into the converted PDF document to avoid font-related issues across different machines and different platforms.
  • Convert a PowerPoint document to PDF with PDF-A1B conformance standards.
  • Specify fallback fonts to be used in place of missing fonts.
  • Skip or include hidden slides.
  • Set the quality of images in the PowerPoint slides to reduce the converted PDF document size.

To use PowerPoint-to-PDF conversion in your application, you can install the following NuGet packages from NuGet.org:

The following code describes how to convert a PowerPoint file to PDF.

//include these namespaces to perform PPTX-to-PDF conversion.
using Syncfusion.Pdf;
using Syncfusion.Presentation;
using Syncfusion.PresentationToPdfConverter;
using System.IO;
 
//Loads the PowerPoint presentation into stream.
using (FileStream fileStreamInput = new FileStream(@"Template.pptx", FileMode.Open, FileAccess.Read))
{
    //Open the existing PowerPoint presentation with loaded stream.
    using (IPresentation pptxDoc = Presentation.Open(fileStreamInput))
    {
        //Create the MemoryStream to save the converted PDF.
        using (MemoryStream pdfStream = new MemoryStream())
        {
            //Convert the PowerPoint document to a PDF document.
            using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc))
            {
                //Save the converted PDF document to MemoryStream.
                pdfDocument.Save(pdfStream);
                pdfStream.Position = 0;
            }
            //Create the output PDF file stream.
            using (FileStream fileStreamOutput = File.Create("Output.pdf"))
            {
                //Copy the converted PDF stream into created output PDF stream.
                pdfStream.CopyTo(fileStreamOutput);
            }
        }
    }
}

Convert PowerPoint to PDF conversion in .NET core and XamarinPowerPoint-to-PDF conversion in .NET core and Xamarin applications

Convert PowerPoint to image in .NET Core and Xamarin

From this release (v17.1) onwards, a PowerPoint slide can be converted to an image (JPEG or PNG) in .NET Core and Xamarin applications.

The following code shows how to convert a PowerPoint slide to an image.

//Namespaces to perform PPTX-to-Image conversion.
using Syncfusion.Presentation;
using Syncfusion.PresentationRenderer;
using System.IO;
 
 
//Load the PowerPoint presentation into stream.
using (FileStream fileStreamInput = new FileStream(@"Template.pptx", FileMode.Open, FileAccess.Read))
{
    //Open the existing PowerPoint presentation with stream.
    using (IPresentation pptxDoc = Presentation.Open(fileStreamInput))
    {
        //Initialize the PresentationRenderer to perform image conversion.
        pptxDoc.PresentationRenderer = new PresentationRenderer();
 
        //Convert PowerPoint slide to image as stream.
        using (Stream stream = pptxDoc.Slides[0].ConvertToImage(ExportImageFormat.Jpeg))
        {
            //Reset the stream position.
            stream.Position = 0;
 
            //Create the output image file stream.
            using (FileStream fileStreamOutput = File.Create("Output.jpg"))
            {
                //Copy the converted image stream into created output stream.
                stream.CopyTo(fileStreamOutput);
            }
        }
     }
}

PowerPoint to image conversion in .NET Core and XamarinPowerPoint-to-image conversion in .NET Core and Xamarin

You can refer to our documentation pages for more information: PowerPoint-to-PDF conversion and PowerPoint-to-image conversion.

Try it out

We hope you’ll like these new features and enhancements included in the 2019 volume 1 release. If you’d like to play around with these new features yourself, please download the latest version from the license and downloads page. Or you can get our NuGet packages from NuGet.org.

If you are new to Syncfusion’s file format libraries, we highly recommend that you follow our user guide. To get started with a desired file format, please follow these links:

If you have any questions or require clarification on these features, please let us know in the comments below. You can also contact us through our support forum or Direct-Trac. We are happy to assist you!

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed