This is a migrated thread and some comments may be shown as answers.

Export to PDF using PdfFormatProvider throws error

1 Answer 49 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ajin prasad
Top achievements
Rank 1
ajin prasad asked on 09 Sep 2013, 03:59 PM
Hi All,

I am using PdfFormatProvider to export PDF document. It throws the error "Index was outside the bounds of the array." in the line provider2.Export(bigbook, output); 

The same code works fine with 
XamlFormatProvider
TxtFormatProvider
HtmlFormatProvider

please see the below code for implementation

  void ExportPDF2_Click(object sender, RoutedEventArgs e)
        {
           this.Cursor = Cursors.Wait;

          

            RadDocument theContent = LoadContent();

            RadDocument bigbook = new RadDocument();
            Section section1 = new Section();
            Paragraph paragraph1 = new Paragraph();

            Span span1 = new Span(TVM.TOC3);
            paragraph1.Inlines.Add(span1);
            section1.Blocks.Add(paragraph1);
            bigbook.Sections.Add(section1);

            
            foreach (Section section in theContent.Sections)
            {
                Section copySection = section.CreateDeepCopy() as Section;
                theContent.Sections.Remove(section);
                bigbook.Sections.Add(copySection);
            }

            this.Cursor = Cursors.Arrow;

            //-----------------------------------------------

            PdfFormatProvider provider2 = new PdfFormatProvider();
           
        
            

            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.DefaultExt = ".pdf";
            saveDialog.Filter = "PDF Document|*.pdf";
            bool? dialogResult = saveDialog.ShowDialog();
            if (dialogResult == true)
            {
                using (System.IO.Stream output = saveDialog.OpenFile())
                {
                    

                    provider2.Export(bigbook, output); //Error at this line
                    MessageBox.Show("Saved Successfully!");
                }
            }
        }

This code works fine with XamlFormatProvider, TxtFormatProvider, HtmlFormatProvider. Issue is only with PDFFormatProvider

Can anyone help me in this?

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 11 Sep 2013, 03:28 PM
Hi,

Please refer to the other forum thread you started on the topic where I provided some suggestions. I hope they are helpful!

Let us know how it goes.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
General Discussions
Asked by
ajin prasad
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or