Unplanned
Last Updated: 10 Jan 2023 09:41 by ADMIN
Tom
Created on: 10 Jan 2023 09:20
Category: PdfViewer
Type: Bug Report
0
RadPdfViewer: KeyNotFoundException when changing Form fields then flattening them and invoking the viewer's Save method
To reproduce: 
        public TestRadForm()
        {
            InitializeComponent();
            this.radPdfViewer1.LoadDocument(@"..\..\..\SampleDocument.pdf");
        }

        private void radButton1_Click(object sender, EventArgs e)
        {
            this.radPdfViewer1.Document.AcroForm.FlattenFormFields();
            this.radPdfViewer1.SaveDocument(@"..\..\saved.pdf");
        }
Attached Files:
1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 10 Jan 2023 09:41

Hi, Tom,

Thank you for reporting this.

Currently, the possible solution that I can suggest is to export the document using the PdfFormatProvider:

            this.radPdfViewer1.PdfViewerElement.EditingFields.FinishEditingWidget();
            this.radPdfViewer1.Document.AcroForm.FlattenFormFields();
            Telerik.Windows.Documents.Fixed.FormatProviders.Pdf .PdfFormatProvider provider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
            using (Stream stream = File.OpenWrite("exported.pdf"))
            {
                provider.Export(this.radPdfViewer1.Document, stream);
            }

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.