Page breaks can be exported and subsequently imported using the "page-break-before: always; " property set of some elements.
Introduce support for break-[before/after] and page-break-[before/after].This can eventually be extended to support "page-break-before: avoid" to preserve the value of the Paragraph.KeepWithNextParagraph property.
Attached to this item is a sample project demonstrating how an HTML file is imported into a RadFlowDocument, the custom page break string are replaced with Break elements of type PageBreak and then the RadFlowDocument is exported to PDF and DOCX files.
When table with table border without color set is created (the color is null), and the document is exported to PDF, ArgumentNullException is thrown. Workaround: Explicitly set a color where the color is null. private void PdfExport() { var tables = this.document.EnumerateChildrenOfType<Table>(); foreach (var table in tables) { TableBorders coloredClone = this.CopyTableBorders_SetColorWhenOmitted(table); table.Borders = coloredClone; using (Stream output = new FileStream(fileName, FileMode.OpenOrCreate)) { provider.Export(this.document, output); } } } private TableBorders CopyTableBorders_SetColorWhenOmitted(Table table) { var leftBorder = new Border(table.Borders.Left.Thickness, table.Borders.Left.Style, table.Borders.Left.Color ?? new ThemableColor(Colors.Transparent), table.Borders.Left.Shadow, table.Borders.Left.Frame, table.Borders.Left.Spacing); var rightBorder = new Border(table.Borders.Right.Thickness, table.Borders.Right.Style, table.Borders.Right.Color ?? new ThemableColor(Colors.Transparent), table.Borders.Right.Shadow, table.Borders.Right.Frame, table.Borders.Right.Spacing); var bottomBorder = new Border(table.Borders.Bottom.Thickness, table.Borders.Bottom.Style, table.Borders.Bottom.Color ?? new ThemableColor(Colors.Transparent), table.Borders.Bottom.Shadow, table.Borders.Bottom.Frame, table.Borders.Bottom.Spacing); var topBorder = new Border(table.Borders.Top.Thickness, table.Borders.Top.Style, table.Borders.Top.Color ?? new ThemableColor(Colors.Transparent), table.Borders.Top.Shadow, table.Borders.Top.Frame, table.Borders.Top.Spacing); var insideHorizontalBorder = new Border(table.Borders.InsideHorizontal.Thickness, table.Borders.InsideHorizontal.Style, table.Borders.InsideHorizontal.Color ?? new ThemableColor(Colors.Transparent), table.Borders.InsideHorizontal.Shadow, table.Borders.InsideHorizontal.Frame, table.Borders.InsideHorizontal.Spacing); var insideVerticalBorder = new Border(table.Borders.InsideVertical.Thickness, table.Borders.InsideVertical.Style, table.Borders.InsideVertical.Color ?? new ThemableColor(Colors.Transparent), table.Borders.InsideVertical.Shadow, table.Borders.InsideVertical.Frame, table.Borders.InsideVertical.Spacing); var tableBorders = new TableBorders(leftBorder, topBorder, rightBorder, bottomBorder, insideHorizontalBorder, insideVerticalBorder); return tableBorders; }
The issue is observed with tables that have a specific width (in inches or percents) but whose columns do not have width specified. MS Word renders such tables expanded to their full width. For tables with 100% width, they have to expand to the entire width of the page. The same behavior is expected in the PDF export. As a common side effect, when specific text alignment (e.g. center or right) is applied to a paragraph within a table cell, and the table is with specified width, but the column is auto-sized (without set width), then the text alignment seems as not respected. Actually the problem is that the column table is shrunk to the text width. Workaround: this may be used before exporting the RadFlowDocument instance to PDF: foreach (Table table in document.EnumerateChildrenOfType<Table>()) { table.LayoutType = TableLayoutType.FixedWidth; } Workaround 2: Set specific width to the auto-sized columns (to any of the cells in the columns): cell.PreferredWidth = new Telerik.Windows.Documents.Flow.Model.Styles.TableWidthUnit(500); Available in R1 2018 SP2 release version.
Office Open XML defines a mechanism for the storage of content which is not defined by this Office Open XML Standard, for example extensions developed by future software applications. The stored data could be an image.
The API should allow the client to navigate to an empty block container and manipulate it. The block containers are Section, TableCell, Header, Footer, Comment. The API should also include manipulation methods for a table like: Add a row to a table. Add a cell to a row. Add a table to an empty cell. Add a paragraph to an empty cell. Add a run to an empty cell. add a text to an empty cell. Move to a next/previous cell. Move to a next/previous row. The API should use the currently applied editor formatting when creating the specified document elements.
The current implementation uses System.Windows.Media.Imaging.BitmapImage class in order to take the image pixels for the PDF export. However, BitmapImage class throws NotSupportedException when being initialized with a WMF or EMF image. WORKAROUND: WMF and EMF images may be converted to PNG images before the PDF export. The following code snippet shows how to convert all inline WMF image to PNG images by using System.Drawing.Image class:private
static
void
ConvertInlineWmfImagesToPng(RadFlowDocument document)
{
foreach
(ImageInline image
in
document.EnumerateChildrenOfType<ImageInline>())
{
if
(image.Image.ImageSource.Extension.Equals(
"wmf"
, StringComparison.InvariantCultureIgnoreCase))
{
using
(MemoryStream wmfImageStream =
new
MemoryStream(image.Image.ImageSource.Data))
{
using
(MemoryStream pngImageStream =
new
MemoryStream())
{
var imageDrawing = System.Drawing.Image.FromStream(wmfImageStream);
imageDrawing.Save(pngImageStream, ImageFormat.Png);
byte
[] pngBytes = pngImageStream.ToArray();
image.Image.ImageSource =
new
ImageSource(pngBytes,
"png"
);
}
}
}
}
}
Add support for setting and exporting document metadata, like Title, Author and similar.
Implement support for pictures with references represented with the r:link attribute in the schema.
Such objects are defined as oleObject elements in the XML:
<w:object w:dxaOrig="3795" w:dyaOrig="3555">
<v:shape id="_x0000_i1026" type="#_x0000_t75" style="width:32.85pt;height:30.55pt" o:ole="" fillcolor="window">
<v:imagedata r:id="rId9" o:title=""/>
</v:shape>
<o:OLEObject Type="Embed" ProgID="PBrush" ShapeID="_x0000_i1026" DrawAspect="Content" ObjectID="_1647182330" r:id="rId10"/>
</w:object>
Currently, they are skipped on import.
Add full support of the font-weight CSS property. The defined values are: normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900. Currently bold and normal are supported.
Is there a way to prevent font embedding in the RadFlow methodology or is utilizing RadFixed the only way to have a reasonably sized PDF document?
Currently Run.Shading is not exported to PDF. Note: This scenario is common when converting HTML to PDF, as Run.Shading is set when construct like <span style="background-color:#ffcc00;"> is used. Workaround: Iterate all the Runs in the already imported HTML document and set their HighlightColor to Shading.BackgroundColor.LocalValue. Check this code snippet:
foreach (Run run in document.EnumerateChildrenOfType<Run>())
{
if (!run.Properties.HighlightColor.HasLocalValue)
{
run.HighlightColor = run.Shading.BackgroundColor.LocalValue;
}
}
When table row is empty, it's exported to PDF with incorrect height - depending on the type of height set with 0 or with the height of an empty paragraph.
Enable the customers to work with .dot files.