Completed
Last Updated: 12 Feb 2025 15:21 by ADMIN
Release 2025.1.205 (2025 Q1)

For example, when some PDF file has uncompressed contents we may import it and apply better compression to the stream objects. Ensure that all the content inside the document is compressed.

Currently, we have the following options for PDF export optimizations:

Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)
 InvalidCastException when importing a file with missing space. The file contains no space between the objects declarations and the page content and this is why the exception occurs.
Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)

When a PDF document is being imported, some of the characters may experience unexpected results while reading the font.

NOTE: the document is displayed in the MAUI/WPF/WinForms PdfViewer controls with missing parts of the text.

Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)
When importing a document, the following error message is observed when reading the Arial, Italic font: System.InvalidCastException: 'Unable to cast object of type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfLiteralString' to type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfName'.'
Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)

When loading some PDF documents with German culture, part of the text got missing.

Workaround: set English culture before loading the document

Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)
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
Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)
When cloning or merging a document containing a Link with Actions collection an exception is thrown: NullReferenceException: 'Object reference not set to an instance of an object.'
Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)

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

 

Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)
Created by: Manikandan
Comments: 0
Category: PdfProcessing
Type: Bug Report
0
NotSupportedException when parsing CFF Type1 font.
Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)
When exporting an image with ICCBased color space and the default ImageCompression is changed an exception is thrown: NotSupportedException: 'Not supported colorspace: ICCBased'.
Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)
NullReferenceException is thrown when importing a file with explicitly set UserInterfaceName annotation property to null.
Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)
After merging documents with PdfStreamWriter the JavaScript actions are broken and not working.
Completed
Last Updated: 12 Feb 2025 15:20 by ADMIN
Release 2025.1.205 (2025 Q1)

When importing a document with a missing state separator (e.g. linefeed) in the object stream (ObjStm) an exception is thrown: System.InvalidCastException: 'Unable to cast object of type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfDictionary' to type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfInt'.'

А possible workaround could be handling the exceptions: Handling Exceptions.

Completed
Last Updated: 12 Feb 2025 15:19 by ADMIN
Release 2025.1.205 (2025 Q1)
Exporting a PDF documents with 2 pages (that are big images) is slow as hell & consuming way too much memory. (for a 2MiB file, over 2GiB!!!)
Completed
Last Updated: 12 Feb 2025 15:19 by ADMIN
Release 2025.1.205 (2025 Q1)

When exporting the pdf pages as images with the Skia engine, some parts of the document got missing.

Note: In the previous Version 2024.3.806 these parts appeared.

Completed
Last Updated: 12 Feb 2025 15:19 by ADMIN
Release 2025.1.205 (2025 Q1)
OverflowException (Arithmetic operation resulted in an overflow.) when converting a document to an image. 
Completed
Last Updated: 12 Feb 2025 15:19 by ADMIN
Release 2025.1.205 (2025 Q1)
Signature omitted after exporting PDF to an image.   
In Development
Last Updated: 12 Feb 2025 15:18 by ADMIN
Scheduled for 2025.1.205 (2025 Q1)

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 });
        }

Under Review
Last Updated: 10 Feb 2025 14:43 by ADMIN

As Ghiath reported in the forum thread, I am seeing this same error.

I am using RadFixedDocument and am generating a PdfFormatProvider. As Ghiath mentioned it will work fine (weeks, months) and then it seems the the font file is locked and it cannot export.

System.IO.IOException: I/O error when opening file 'C:\WINDOWS\FONTS\MSYH.TTC'.

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IO.IOException: I/O error when opening file 'C:\WINDOWS\FONTS\MSYH.TTC'.
   at MS.Internal.FontCache.FileMapping.OpenFile(String fileName)
   at MS.Internal.FontCache.FontSource.GetUnmanagedStream()
   at System.Windows.Media.GlyphTypeface.ComputeSubset(ICollection`1 glyphs)
   at Telerik.Windows.Documents.Fixed.Model.Fonts.CidType2Font.ComputeSubset(IEnumerable`1 usedCharacters)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontStream.CopyPropertiesFromOverride(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontStream.CopyPropertiesFrom(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontDescriptor.CreateFontFile(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontDescriptor.ExportFontFile(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontDescriptor.CopyPropertiesFrom(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.CidFontObject.CopyPropertiesFromOverride(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.CidFontObject.CopyPropertiesFrom(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.Type0FontObject.CopyPropertiesFromOverride(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.WriteFontsFromContext(PdfWriter writer, IPdfExportContext context)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.Export(IRadFixedDocumentExportContext context, Stream output)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFixedDocument document, Stream output)
   at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
 

It will throw the exception on the line where it is doing the export. The document is typically a multi-page document with images, etc. As I mentioned it might work fine for weeks and then once it fails the only solution is to recycle the web service.

Unplanned
Last Updated: 14 Jan 2025 13:52 by ADMIN
It seems the font that is rendered in Adobe is not the same. The document does not contain the font and Adobe and PdfViewer are fallbacking to different fonts.