Currently, we support inserting png, jpg and other raster graphic images. Provide a way to insert image from SVG (vector graphic image format), by creating a FormSource from its parsed XML.
Highlight annotations appear as highlights in the text of a document. When opened, they display a pop-up window containing the text of the associated note.
It will be possible to add an SVG element in a RadFixedPage so that it can be exported to PDF via the RadPdfProcessing library.
This is the code for inserting the image:
static void Main(string[] args)
{
FixedExtensibilityManager.ImagePropertiesResolver = new ImagePropertiesResolver();
//Telerik.Windows.Documents.Extensibility.JpegImageConverterBase defaultJpegImageConverter = new Telerik.Documents.ImageUtils.JpegImageConverter();
//Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = defaultJpegImageConverter;
//Output("fyb-64.png", "output-working.pdf");
Output("fyb.png", "output-broken.pdf");
}
private static void Output(string resourceName, string outputFileName)
{
var document = new RadFixedDocument();
using (var editor = new RadFixedDocumentEditor(document))
{
Stream image = new FileStream(resourceName, FileMode.Open);
var table = new Table
{
LayoutType = TableLayoutType.FixedWidth,
Margin = new Thickness(10, 0, 0, 0),
};
var row = table.Rows.AddTableRow();
var cell = row.Cells.AddTableCell();
var block = cell.Blocks.AddBlock();
block.InsertImage(image);
editor.InsertTable(table);
var pdfData = ExportToPdf(document);
File.Delete(outputFileName);
File.WriteAllBytes(outputFileName, pdfData);
Process.Start(new ProcessStartInfo() { FileName = outputFileName, UseShellExecute = true });
}
}
private static byte[] ExportToPdf(RadFixedDocument document)
{
byte[] pdfData;
using (var ms = new MemoryStream())
{
var pdfFormatProvider = new PdfFormatProvider();
pdfFormatProvider.Export(document, ms);
pdfData = ms.ToArray();
}
return pdfData;
}
Workaround: Instead of setting the ImagePropertiesResolver, set the JpegImageConverter:
Telerik.Windows.Documents.Extensibility.JpegImageConverterBase defaultJpegImageConverter = new Telerik.Documents.ImageUtils.JpegImageConverter();
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = defaultJpegImageConverter;
Search for specific text in a PDF document and you will notice that if the document is landscape, the SearchResult.GetWordBoundingRect method may return incorrect results. If the document is Portrait, the exact results are highlighted with the code snippet below:
PdfFormatProvider provider = new PdfFormatProvider();
RadFixedDocument document = provider.Import(File.ReadAllBytes("Landscape.pdf"));
TextSearch searchText = new TextSearch(document);
TextSearchOptions searchOptions = new TextSearchOptions { UseRegularExpression=false, CaseSensitive=false, WholeWordsOnly = true };
IEnumerable<SearchResult> matchResults = searchText.FindAll("sed", searchOptions);
foreach (SearchResult resultItem in matchResults)
{
Rect rect = resultItem.GetWordBoundingRect();
RadFixedPage page = resultItem.GetResultPage();
FixedContentEditor editor = new FixedContentEditor(page);
editor.GraphicProperties.FillColor = new RgbColor(125, 255, 0, 0);
editor.DrawRectangle(rect);
}
string outputFilePath = "result.pdf";
File.Delete(outputFilePath);
File.WriteAllBytes(outputFilePath, provider.Export(document));
Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });
Landscape: wrong rectangles are highlighted
Portrait: correct rectangles are highlighted:
System.OutOfMemoryException: Insufficient memory to continue the execution of the program. at System.Text.StringBuilder.ExpandByABlock(Int32 minBlockCharCount) at System.Text.StringBuilder.AppendWithExpansion(Char value) at System.Text.StringBuilder.Append(Char value) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Utilities.CrossReferenceCollectionReader.GetAllText(Reader reader, Int64 minOffset, Int64 maxOffset) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Utilities.CrossReferenceCollectionReader.FindAllObjectOffsets(Reader reader, Dictionary`2 tokenToOffsets, Int64 minOffset, Int64 maxOffset)
When exporting a document with the .NET Framework implementation, only subsets of the used fonts are embedded in the document. This is currently not available in the Silverlight implementation, and it most probably won't be available in the .NET Standard implementation, as the current implementation is dependent on the WPF font classes. Provide API to plug similar logic when using different platforms as well.
This item wil handle the TrueType OpenType Font format. For the Compact Font Format (CFF) please follow: Export subset of Compact Font Format (CFF) fonts for platforms different than .NET Framework
NullReferenceException is thrown when Find API is used on a newly created document.
Workaround: Export - Import the document before using the Find API
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
byte[] exportedDocument = pdfFormatProvider.Export(document);
document = pdfFormatProvider.Import(exportedDocument);
Encoding table headers are preserved when creating subsets.
As a result of the below missing operator, some of the glyphs can't be extracted from the CFFFontTable and the characters are not displayed in the PdfViewer:
The end user result is missing letter from the PDF content.
Square annotation displays a rectangle on the page. When opened, it displays a pop-up window containing the text of the associated note.
When an import of the attached PDF file is executed, the result is a file with vertically rotated images, as well as enlarged and distorted. This is part of the code executed in the final application. Do you have any idea why this is happening? Is there any suggested solution?
As a result of the imported file, other processes are executed, such as creating bookmarks and page numbering, but the result is incorrect when presenting the rotated images.
Please find attached a code snippet and the input and generated output file.
Thank you.
private static void TestPDF()
SkiaImageFormatProvider: Rectangle behind text overlaps the text of previous line.
RESOLVED: The issue is dismissed. The actual reason for the results is missing FontsProvider implementation. In order for accurate calculations and measurements the fonts used in the document need to be resolved correctly.