Export to PDF using PdfFormatProvider throws error

2 posts, 0 answers
  1. ajin prasad
    ajin prasad avatar
    19 posts
    Member since:
    May 2010

    Posted 09 Sep 2013 Link to this post

    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?
  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 11 Sep 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top