This post details some of the features we expect to ship in our next major release (v20.2). If you own an active Universal or DXperience subscription, you can download our Early Access Preview (EAP) build today. To test the functionality described herein, simply navigate to our Download Manager to obtain the appropriate installer.
As always, we thank you for choosing our Office-inspired component libraries and for placing your faith in DevExpress.
Remember, Early Access and CTP builds are provided solely for early testing purposes and are not ready for production use. This build can be installed side by side with other major versions of DevExpress products. Please backup your project and important data before installing Early Access and CTP builds.
Perhaps most importantly, this EAP does not include all features/products we expect to ship in our v20.2 release cycle. We are working hard to finalize all v20.2 features/capabilities and once we have more information to share, we’ll post updates on this channel.
PDF Document API
Cross-Platform Rendering
Our PDF Document API (v20.2) will allow you to use the Skia Graphics Engine to render page content on any supported platform (Windows, Linux, or Azure).
If you’re using our Office File API on Linux, add the DevExpress.Pdf.SkiaRenderer NuGet package.
This Skia Graphics Engine allows you to render graphical elements within Azure, even with Azure plans that prohibit GDI calls (such as the Basic plan). To activate the cross-platform engine in an Azure service project, add a reference to the DevExpress.Pdf.SkiaRenderer package and set the PdfDocumentProcessor.RenderingEngine property to PdfRenderingEngine.Skia. You can also use this property on Windows OS to deliver unified rendering/output.
Draw Page Content
The PdfGraphics.DrawPageContent method allows you to insert page content to a different page. When used, you can merge the contents of two separate pages into one.
The code below inserts a portion of a page to a document. The content is scaled and inserted at the bottom of the page:
using DevExpress.Pdf;
using System.Drawing;
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
processor.CreateEmptyDocument();
PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
using (PdfDocumentProcessor processor2 = new PdfDocumentProcessor())
{
processor2.LoadDocument(@"Demo.pdf");
using (PdfGraphics graphics = processor.CreateGraphics())
{
graphics.SaveGraphicsState();
//Define position for the content on your target page:
graphics.TranslateTransform((float)(page.CropBox.Width * 1 / 3),
(float)(page.CropBox.Height * 4 / 5));
PdfRectangle clip = processor2.Document.Pages[0].CropBox;
//Resize source page content to fit the target page:
float scaleFactor = (float)(page.CropBox.Width / clip.Width / 3);
graphics.ScaleTransform(scaleFactor,scaleFactor);
//Crop source content:
graphics.IntersectClip(new RectangleF((float)clip.Left, (float)(clip.Top / 2.8),
(float)clip.Width, (float)(clip.Height / 2.8)));
//Draw the cropped segment in the target page:
graphics.DrawPageContent(processor2.Document.Pages[0]);
graphics.RestoreGraphicsState();
//Apply changes:
graphics.AddToPageForeground(page, 72, 72);
}
}
processor.SaveDocument("result.pdf");
}
Page Manipulation Enhancements
You can now execute the following actions on PDF page content:
- Scale content
- Specify content offset
- Rotate content
- Resize the page. Content aspect ratio is maintained.
The code below demonstrates the use of these PdfPage class methods:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
processor.CreateEmptyDocument();
processor.LoadDocument(@"Document.pdf");
//Set offset for content on the first page:
processor.Document.Pages[0].OffsetContent(50, 100);
//Scale and rotate the content on the second page:
processor.Document.Pages[1].ScaleContent(0.5, 0.5);
processor.Document.Pages[1].RotateContent(200, 100, 270);
//Resize the third page:
processor.Document.Pages[2].Resize(PdfPaperSize.Legal,
PdfContentHorizontalAlignment.Center, PdfContentVerticalAlignment.Center);
processor.SaveDocument("result.pdf");
}
Word Processing Document API
Load Document Properties
Our Word Processing Document API (v20.2) allows you to load document metadata (or document properties) without loading the document itself. You can use retrieved information to search for a specific document, catalogue files, or collect statistics as needed.
The code below uses document metadata to sort files by modification date:
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using System;
using System.IO;
using System.Diagnostics;
static void Main(string[] args)
{
DirectoryInfo directoryInfo =
new DirectoryInfo(@"C:\Users\Public\Documents\DevExpress Demos 20.2\Components\Data");
FileInfo[] files = directoryInfo.GetFiles("*.docx");
foreach (FileInfo file in files)
{
SortDocuments(file.FullName, file.Name);
}
Process.Start("explorer.exe", @"C:\Documents");
}
public static void SortDocuments(string filePath, string fileName)
{
using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
//Load metadata from the specified document:
ReadOnlyDocumentProperties docProperties =
wordProcessor.LoadDocumentProperties(filePath);
DateTime date = docProperties.BuiltIn.Modified;
//Check the year the document was last modified,
//And copy the file to the corresponding folder:
switch (date.Year)
{
case 2019:
File.Copy(filePath, string.Format("C://Documents//2019//{0}", fileName), true);
break;
case 2020:
File.Copy(filePath, string.Format("C://Documents//2020//{0}", fileName), true);
break;
}
}
}
Asynchronous Load and Save
Our new API allows you to load, save, and export documents to PDF and HTML asynchronously. Use the following new methods (RichEditDocumentExtensions class) as needed:
- RichEditDocumentServerExtensions.LoadDocumentAsync
- RichEditDocumentServerExtensions.LoadDocumentTemplateAsync
- RichEditDocumentServerExtensions.SaveDocumentAsync
- RichEditDocumentServerExtensions.ExportToPdfAsync
These methods can accept a CancellationToken as a parameter. This allows you to terminate the operation when appropriate.
The example below merges two documents and saves results asynchronously.
private async void MergeDocuments()
{
using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
using (RichEditDocumentServer wordProcessor2 = new RichEditDocumentServer())
{
await Task.WhenAll(new Task[]
{
wordProcessor.LoadDocumentAsync("Document1.docx"),
wordProcessor2.LoadDocumentAsync("Document2.docx")
});
wordProcessor.AppendDocumentContent(wordProcessor2.Document.Range);
await wordProcessor.SaveDocumentAsync("merged.docx", DocumentFormat.OpenXml);
}
}
Word Processing (Office File API, WinForms, WPF)
New File Formats Support
Our Word Processing Document API and both WinForms and WPF Rich Text Editor controls now support the following file formats:
- DOCM (Microsoft Office Open XML Macro-Enabled Document format)
- DOT (Microsoft Word 97-2003 Template format)
- DOTM (Microsoft Office Open XML Macro-Enabled Template format)
- DOTX (Microsoft Office Open XML Template format)
- FlatOpc XML (Microsoft Word XML Document stored in a flat XML file instead of a ZIP package).
“Fill in Forms” Protection
You can now specify “Fill in Forms” protection in code and via the component’s UI.
Rich Text Editor (WinForms and WPF)
Footnotes and Endnotes UI
The Rich Text Editor for WinForms and WPF ship with new UI elements designed to insert, navigate, and format footnotes and endnotes.
Spreadsheet (WPF)
New Layout Engine
Our WPF Spreadsheet control ships with a new layout calculation engine. This new engine improves layout accuracy, increases render and scroll performance, and enhances PDF export and printing capabilities.
Please note that this update modifies the manner in which our Spreadsheet control renders and prints certain documents. Activate the SpreadsheetCompatibilityOptions.EnableLegacyLayoutEngine option to revert to our legacy layout engine when appropriate.
<dxsps:SpreadsheetControl.Options>
<dxsps:SpreadsheetControlOptions>
<dxsps:SpreadsheetControlOptions.Compatibility>
<dxsps:SpreadsheetCompatibilityOptions EnableLegacyLayoutEngine="True"/>
</dxsps:SpreadsheetControlOptions.Compatibility>
</dxsps:SpreadsheetControlOptions>
</dxsps:SpreadsheetControl.Options>
Rich Text Support in Spreadsheet Cells
Our WPF Spreadsheet control can now display rich text within worksheet cells. Documents with rich text can also be printed and exported to PDF. This capability is only available if our new layout calculation engine is used.
Note: The WPF Spreadsheet control does not allow you to apply rich formatting to cell text via the control’s UI. Use our Rich Text API to create rich text in code and assign it to a cell.
Your Feedback Matters
We realize beta-testing is a time-consuming process and we are grateful to those who invest time with our preview builds. Find the current implementation lacking flexibility? Feel we've overlooked a valuable usage scenario? Does our current implementation fail to address your business requirements? Please post your thoughts in the comment section below or create a Support Center ticket. We will happily follow-up and do what we can to extend the capabilities of our new products/features.