Completed
Last Updated: 07 Aug 2024 15:19 by ADMIN
Release 2024.3.806 (2024 Q3)
ADMIN
Martin
Created on: 06 Aug 2024 10:31
Category: PdfProcessing
Type: Bug Report
0
PdfProcessing: InvalidCastException is thrown on import when culture with comma (,) decimal separator set

When Cyrillic culture is set an InvalidCastException is thrown.

Workaround: use English culture during the import process

            System.Globalization.CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-EN");
            PdfFormatProvider provider = new PdfFormatProvider();
            RadFixedDocument document;
            using (Stream stream = File.OpenRead("popup_dedetizacao_ok.pdf"))
            {
                document = provider.Import(stream);
            }
            System.Threading.Thread.CurrentThread.CurrentCulture = currentCulture;
        

For the RadPdfViewer control you can use a similar approach: 

            System.Globalization.CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-EN");
            PdfFormatProvider provider = new PdfFormatProvider();
            RadFixedDocument document;
            using (Stream stream = File.OpenRead("popup_dedetizacao_ok.pdf"))
            {
                document = provider.Import(stream);
            }
            System.Threading.Thread.CurrentThread.CurrentCulture = currentCulture;

            RadForm form = new RadForm();
            RadPdfViewer radPdfViewer1 = new RadPdfViewer();
            form.Controls.Add(radPdfViewer1);
            radPdfViewer1.LoadElementTree();
            radPdfViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
            radPdfViewer1.Document = document;
             
            form.ShowDialog();

 

0 comments