When creating a GradientStop, an alpha channel of the color could be applied. However, this setting is not respected it the result document and the gradient is with full opacity. Steps to reproduce: 1. Create a gradient with an alpha channel: RadFixedDocument document = new RadFixedDocument(); RadFixedPage page = document.Pages.AddPage(); FixedContentEditor containerEditor = new FixedContentEditor(page); LinearGradient linearGradient = new LinearGradient(new Point(0, 0), new Point(30, 30)); linearGradient.GradientStops.Add(new GradientStop(new RgbColor(10, 0, 207, 0), 0)); linearGradient.GradientStops.Add(new GradientStop(new RgbColor(10, 0, 102, 204), 1)); containerEditor.GraphicProperties.FillColor = linearGradient; containerEditor.DrawRectangle(new Rect(10, 10, 48, 29)); 2. Export the document to PDF Observed: The alpha channel is not respected and the gradient is with full opacity
The issue may be reproduced by opening the attached PDF in Adobe Reader. Although the viewer initially shows the characters correctly, when you start typing in the TextBox, the umlaut/diacritics characters get corrupted. In other PDF viewers, the umlaut characters are handled correctly, so the issue seems to related to concrete Adobe Reader encoding handling implementation. The diacritic characters are handled incorrectly in other viewers as well (e.g. Chrome).
byte[] data = File.ReadAllBytes("verdana.ttf");
FontFamily verdanaRegularFontFamily = new FontFamily("Verdana");
FontsRepository.RegisterFont(verdanaRegularFontFamily, FontStyles.Normal, FontWeights.Normal, data);
FontsRepository.TryCreateFont(verdanaRegularFontFamily, out FontBase verdanaRegularFont);
foreach (RadFixedPage page in mergedDocument.Pages)
{
foreach (TextFragment textFragment in page.Content.Where(c => c is TextFragment).Cast<TextFragment>())
{
textFragment.Font = verdanaRegularFont;
}
}
This exception was originally thrown at this call stack:
System.ThrowHelper.ThrowKeyNotFoundException()
System.Collections.Generic.Dictionary<TKey, TValue>.this[TKey].get(TKey)
Telerik.Windows.Documents.Core.PostScript.Data.PostScriptDictionary.GetElementAs<T>(string) in PostScriptDictionary.cs
Telerik.Windows.Documents.Core.Fonts.Type1.Type1Format.Dictionaries.Type1Font.ReadGlyphData(string) in Type1Font.cs
Telerik.Windows.Documents.Core.Fonts.Type1.Type1Format.Dictionaries.Type1Font.GetGlyphDataInternal(string) in Type1Font.cs
This exception was originally thrown at this call stack:
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.PageTreeNode.EnumeratePages(Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.Parser.PostScriptReader, Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.IPdfImportContext) in PageTreeNode.cs
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.PageTreeNode.EnumeratePages(Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.Parser.PostScriptReader, Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.IPdfImportContext) in PageTreeNode.cs
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyPagePropertiesTo(Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.Parser.PostScriptReader, Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.IRadFixedDocumentImportContext) in DocumentCatalog.cs
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyPropertiesTo(Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.Parser.PostScriptReader, Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.IRadFixedDocumentImportContext) in DocumentCatalog.cs
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.RadFixedDocumentImportContext.BeginImportOverride() in RadFixedDocumentImportContext.cs
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.BaseImportContext.BeginImport(System.IO.Stream) in BaseImportContext.cs
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.PdfImporter.Import(System.IO.Stream, Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.IPdfImportContext) in PdfImporter.cs
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ImportOverride.AnonymousMethod__0() in PdfFormatProvider.cs
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.ExceptionHandling.ExecutionHandler.TryHandleExecution<E>(System.Action) in ExecutionHandler.cs
After the import-export of a specific document, the paths are thinner and the corners of the path figure are not rounded:
This is the code snippet for reproducing the error message:
static void Main(string[] args)
{
string filePath = "Lorem ipsum dolor sit amet.pdf";
//load a random document
PdfFormatProvider provider = new PdfFormatProvider();
RadFixedDocument originalDocument;
using (Stream stream = File.OpenRead(filePath))
{
originalDocument = provider.Import(stream);
}
//draw something on the first page
FixedContentEditor editor = new FixedContentEditor(originalDocument.Pages[0]);
editor.GraphicProperties.IsFilled = true;
editor.GraphicProperties.FillColor = RgbColors.Black;
Telerik.Documents.Primitives.Rect Rect = new Telerik.Documents.Primitives.Rect(10, 10, 200, 100);
editor.DrawRectangle(Rect);
//export the pages as images and build a brand new document from the images
SkiaImageFormatProvider imageProvider = new SkiaImageFormatProvider();
imageProvider.ExportSettings.ImageFormat = SkiaImageFormat.Jpeg;
imageProvider.ExportSettings.ScaleFactor = 0.8;
imageProvider.ExportSettings.Quality = 80;
RadFixedDocument doc = new RadFixedDocument();
foreach (RadFixedPage page in originalDocument.Pages)
{
byte[] resultImage = imageProvider.Export(page);
RadFixedPage pdfpage = doc.Pages.AddPage();
editor = new FixedContentEditor(pdfpage);
Stream imageStream = new MemoryStream(resultImage);
editor.DrawImage(imageStream);
}
//export the pdf built from the images
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
string outputPdf = @"output.pdf";
File.Delete(outputPdf);
using (Stream output = File.OpenWrite(outputPdf))
{
pdfFormatProvider.Export(doc, output);
}
Process.Start(new ProcessStartInfo() { FileName = outputPdf, UseShellExecute = true });
}
Workaround:
static void Main(string[] args)
{
string filePath = "Lorem ipsum dolor sit amet.pdf";
//load a random document
PdfFormatProvider provider = new PdfFormatProvider();
RadFixedDocument originalDocument;
using (Stream stream = File.OpenRead(filePath))
{
originalDocument = provider.Import(stream);
}
//draw something on the first page
FixedContentEditor editor = new FixedContentEditor(originalDocument.Pages[0]);
editor.GraphicProperties.IsFilled = true;
editor.GraphicProperties.FillColor = RgbColors.Black;
Telerik.Documents.Primitives.Rect Rect = new Telerik.Documents.Primitives.Rect(10, 10, 200, 100);
editor.DrawRectangle(Rect);
using (Stream output = File.OpenWrite(filePath))
{
provider.Export(originalDocument, output);
}
using (Stream stream = File.OpenRead(filePath))
{
originalDocument = provider.Import(stream);
}
//export the pages as images and build a brand new document from the images
SkiaImageFormatProvider imageProvider = new SkiaImageFormatProvider();
imageProvider.ExportSettings.ImageFormat = SkiaImageFormat.Jpeg;
imageProvider.ExportSettings.ScaleFactor = 0.8;
imageProvider.ExportSettings.Quality = 80;
RadFixedDocument doc = new RadFixedDocument();
foreach (RadFixedPage page in originalDocument.Pages)
{
byte[] resultImage = imageProvider.Export(page);
RadFixedPage pdfpage = doc.Pages.AddPage();
editor = new FixedContentEditor(pdfpage);
Stream imageStream = new MemoryStream(resultImage);
editor.DrawImage(imageStream);
}
//export the pdf built from the images
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
string outputPdf = @"output.pdf";
File.Delete(outputPdf);
using (Stream output = File.OpenWrite(outputPdf))
{
pdfFormatProvider.Export(doc, output);
}
Process.Start(new ProcessStartInfo() { FileName = outputPdf, UseShellExecute = true });
}
Wrong calculations of new lines and white spaces between characters due to a wrong calculated character`s BoundingRect.
This results in missing whitespaces and/or characters split between lines.
NumberedHierarchical list type has inconsistent indentation after bullets.
If a PDF with a TextBoxField is created with a corresponding Widget, the text is actually long enough to be broken in more than one line and AllowScroll is set to true, upon opening the file in Adobe, the text is not visible. The field actually does have an appearance which can be seen upon inspection of the document but for some reason it is not visualized. Another issue seems to be a different manifestation of the same problem: When the text is long and AllowScroll is false, the text will be visible, but will be misplaced. The issue is caused by the length of the text because the same field with a shorter text that can fit in the widget's rectangle will be displayed correctly.