bug on UpdateLayout()?

4 posts, 0 answers
  1. Chris
    Chris  avatar
    42 posts
    Member since:
    Apr 2009

    Posted 23 Aug 2011 Link to this post

    Hi, there.
    I think RadBook is a great component for document viewer.
    The problem is that I need to change the Width and Height of the viewer and the contents need to reformat the pages to fit in.
    I tested code based on "RadBookIntegration" sample by adding the follwoing code.

           private void RadButtonIncrease_Click(object senderRoutedEventArgs e)
            {
                RadDocument doc = this.viewManager.Document;
                doc.DefaultPageLayoutSettings.Width += 50;
                doc.DefaultPageLayoutSettings.Height += 50;
                doc.UpdateLayout();
            }
            private void RadButtonDecrease_Click(object senderRoutedEventArgs e)
            {
                RadDocument doc = this.viewManager.Document;
                doc.DefaultPageLayoutSettings.Width -= 50;
                doc.DefaultPageLayoutSettings.Height -= 50;
                doc.UpdateLayout();
            }

    I believe UpdateLayout should reformat the contents but the result is not what I expected;  page numbers and contents gets duplicated.
    Can you please tell me what I'm doing wrong?

    Thanks for your help.

  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 26 Aug 2011 Link to this post

    Hi Chris ,

    Unfortunately, changing the page layout settings after the document has been shown in the Book is not supported. What you can do is create a copy of the document, set different values for Width and Height and then assign it to the book. Here is a sample implementation of that:

    private void RadButtonIncrease_Click(object sender, RoutedEventArgs e)
    {
        RadDocument doc = this.viewManager.Document.CreateDeepCopy() as RadDocument;
        if (doc.DefaultPageLayoutSettings.Width + 50 < this.book.Width)
        {
            doc.DefaultPageLayoutSettings.Width += 50;
        }
        if (doc.DefaultPageLayoutSettings.Height + 50 < this.book.Height)
        {
            doc.DefaultPageLayoutSettings.Height += 50;
        }
        doc.UpdateLayout();
        this.viewManager.Document = doc;
        bindingSource.Document = doc;
        this.book.UpdateLayout();
    }
     
    private void RadButtonDecrease_Click(object sender, RoutedEventArgs e)
    {
        RadDocument doc = this.viewManager.Document.CreateDeepCopy() as RadDocument;
        if (doc.DefaultPageLayoutSettings.Width - 50 > this.book.Width)
        {
            doc.DefaultPageLayoutSettings.Width -= 50;
        }
        if (doc.DefaultPageLayoutSettings.Height - 50 > this.book.Height)
        {
            doc.DefaultPageLayoutSettings.Height -= 50;
        }
        doc.UpdateLayout();
        this.viewManager.Document = doc;
        bindingSource.Document = doc;
        this.book.UpdateLayout();
    }

    As you will probably notice, it may cause performance issues with bigger documents. We will consider making some changes to the RadBook and RadRichTextPageView controls in order to make such scenarios more straight-forward for implementation.

    Greetings,
    Iva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Chris
    Chris  avatar
    42 posts
    Member since:
    Apr 2009

    Posted 29 Aug 2011 Link to this post

    Thanks for the info but let me ask you a question.
    Is this consider as a bug? If it is, the name UpdateLayout somewhat misleading.
    If it's not a bug, the name should change to something else.
    Thanks.

      
  5. Mike
    Admin
    Mike avatar
    640 posts

    Posted 02 Sep 2011 Link to this post

    Hello Chris,

    We will consider this limitation as a bug a try to resolve it for the next major release. Let us know if the workaround suits your app at this point.

    All the best,
    Mike
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top