Unplanned
Last Updated: 18 Apr 2024 15:38 by John

When calling a PDF export in a high-concurrency environment the internal state can get corrupted because it uses a non-thread safe collection internally.

Sample code:

void WriteToPdf(RadFlowDocument document, Stream outputStream) {

   PdfFormatProvider pdfWriter = new() {};

   pdfWriter.Export(document, outputStream);
}

When calling it like this:

Parallel.ForEachAsync(listOfDocuments, (document, _) => {
   WriteToPdf(document, Stream.Null);
});

An exception may occur:

System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
   at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
   at Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.TryCreateFont(FontFamily fontFamily, FontStyle fontStyle, FontWeight fontWeight, FontBase& font)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Utils.Extensions.CopyPropertiesFrom(CharacterProperties fixedProperties, PdfExportContext context, CharacterProperties properties)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.CreateListLevel(ListLevel flowLevel)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.CreateList(List flowList)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.ExportDocument(RadFlowDocument document, RadFixedDocumentEditor editor)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.ExportInternal()
   at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
   at xxxxx.Application.Common.PdfGeneration.PdfWriter.WriteToPdf(RadFlowDocument document, Stream outputStream) 

The state is then corrupted forever, until the application is restarted.

Realistic scenario where this is also reproduced: Web application that generates PDFs and is called concurrently.

 

In Development
Last Updated: 18 Apr 2024 12:13 by ADMIN
When merging documents with exactly the same font but different character widths, some characters are rendered with the wrong width.

In Development
Last Updated: 18 Apr 2024 12:11 by ADMIN

This is the code used for merging:

        private  void MergeDifferentDocumentsPagesWithFixed()
        {
            string[] documentsToMerge =
            {
                "14301-STOCK_Proforma.pdf",
                "14302-STOCK_Proforma.pdf",
                "14303-STOCK_Proforma.pdf",
                "14304-STOCK_Proforma.pdf",
                "14305-STOCK_Proforma.pdf",
                "14330-STOCK_Proforma.pdf"
            };
            RadFixedDocument doc = new RadFixedDocument();
            PdfFormatProvider provider = new PdfFormatProvider();
            foreach (string current_item in documentsToMerge)
            {
                string path = @"..\..\Samples\" + current_item;
                RadFixedDocument docToMerge;
                if (!File.Exists(path))
                {
                    continue;
                }
                using (Stream stream = File.OpenRead(path))
                {
                    docToMerge = provider.Import(stream);
                }
                doc.Merge(docToMerge);
            }


            string outputFilePath = @"..\..\mergedFixed.pdf";
            File.Delete(outputFilePath);

            using (Stream output = File.OpenWrite(outputFilePath))
            {
                provider.Export(doc, output);
            }
            Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });


        }

Workaround:  

   private void MergeDifferentDocumentsPages(string resultFileName)
   {
       string[] documentsToMerge =
       {
           "14301-STOCK_Proforma.pdf",
           "14302-STOCK_Proforma.pdf",
           "14303-STOCK_Proforma.pdf",
           "14304-STOCK_Proforma.pdf",
           "14305-STOCK_Proforma.pdf",
           "14330-STOCK_Proforma.pdf"
       };

       File.Delete(resultFileName);
       using (PdfStreamWriter fileWriter = new PdfStreamWriter(File.OpenWrite(resultFileName)))
       {
           foreach (string documentName in documentsToMerge)
           {
               string path = @"..\..\Samples\" + documentName;
               using (PdfFileSource fileToMerge = new PdfFileSource(File.OpenRead(path)))
               {
                   foreach (PdfPageSource pageToMerge in fileToMerge.Pages)
                   {
                       fileWriter.WritePage(pageToMerge);
                   }
               }
           }
       }


      
       Process.Start(new ProcessStartInfo() { FileName = resultFileName, UseShellExecute = true });
   }

Duplicated
Last Updated: 18 Apr 2024 06:22 by ADMIN
Created by: Martin
Comments: 0
Category: PdfProcessing
Type: Feature Request
2
An implementation of JPXDecoder should be created to allow the decompression of data encoded using the wavelet-based JPEG2000 standard.

Guidelines of how to provide a custom implementation of the JPXDecode filter can be found in the Customize Rendering section of the documentation and a sample implementation can be found in the SDK examples.
Unplanned
Last Updated: 18 Apr 2024 05:36 by Sujith

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

Unplanned
Last Updated: 17 Apr 2024 12:39 by Nathan
Created by: Nathan
Comments: 0
Category: WordsProcessing
Type: Bug Report
1
PdfFormatProvider: TOC entries are blue.
Unplanned
Last Updated: 17 Apr 2024 12:31 by Nathan
TOC list numbering and page numbering are missing.
Unplanned
Last Updated: 17 Apr 2024 12:18 by Nathan
PdfFormatProvider: TOC page numbering is in Roman instead of Arabic numerals.
Unplanned
Last Updated: 17 Apr 2024 11:56 by Nathan
Calculate TOC page numbering based on page number fields.
Unplanned
Last Updated: 17 Apr 2024 10:24 by Joshua
Created by: Joshua
Comments: 0
Category: SpreadProcessing
Type: Feature Request
1
Make the CsvParser public.
Unplanned
Last Updated: 17 Apr 2024 10:22 by Steve
Created by: Steve
Comments: 0
Category: SpreadProcessing
Type: Feature Request
1
Add support for image cropping (a:srcRect). 
In Development
Last Updated: 16 Apr 2024 11:12 by ADMIN
ArgumentNullException when importing documents containing comments with no DateTime.
In Development
Last Updated: 16 Apr 2024 11:02 by ADMIN
Unplanned
Last Updated: 15 Apr 2024 13:10 by Belma
Created by: Belma
Comments: 0
Category: WordsProcessing
Type: Bug Report
0
Outline color of some shapes is not respected.
In Development
Last Updated: 15 Apr 2024 12:43 by ADMIN
Created by: IGNACIO
Comments: 0
Category: WordsProcessing
Type: Feature Request
1
The AlternateContent element is used to store content which is not defined by the specification.
In Development
Last Updated: 15 Apr 2024 08:37 by ADMIN
When parsing a CFF Type1 font a NullReferenceException is thrown.
In Development
Last Updated: 12 Apr 2024 20:51 by ADMIN

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

In Development
Last Updated: 12 Apr 2024 20:51 by ADMIN
ADMIN
Created by: Deyan
Comments: 4
Category: PdfProcessing
Type: Feature Request
14
Currently, when registering *.otf font file with FontsRepository.RegisterFont method an exception is thrown during the font creation. 

WORKAROUND:  The font file may be converted to TTF format (*.ttf) which is successfully registered. This conversion may be achieved with FontForge by opening the font file and then choosing File -> Generate Fonts -> TrueType -> Generate. More information on FontForge program may be found here: https://fontforge.github.io/en-US/
In Development
Last Updated: 12 Apr 2024 20:51 by ADMIN

Currently, a NullReferenceException is thrown because of the incorrect structure. 

As a workaround the exception can be handled using the Handling Exceptions mechanism.

In Development
Last Updated: 12 Apr 2024 20:50 by ADMIN

According to the PDF specification:
A clipping path operator (W or W*) may appear after the last path construction operator and before the path-painting operator that terminates a path object.

Invalid:

W                          % clipping path operator
0 0 m                     % start of the path construction
596 0 l
596 842 l
0 842 l
h                            % end of the path construction
n                            % path-painting operator
Valid:
0 0 m
596 0 l
596 842 l
0 842 l
h
W
n

Currently (in the invalid cases), the path construction is skipped on import.

1 2 3 4 5 6