PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Can't navigate to a page in DocumentViewer !?!
http://forum.pdfsharp.de/viewtopic.php?f=2&t=2252
Page 1 of 1

Author:  brad [ Sun Dec 02, 2012 12:56 pm ]
Post subject:  Can't navigate to a page in DocumentViewer !?!

Hi there,
I cannot get DocumentPreview.Page working - is there a bug?
In the provided samples for MigraDoc v1.32 based on WPF, in the DocumentViewer project I enter the code:
Code:
 preview.Page = 3;

but the document viewer does not jump to page 3, nor does:
Code:
preview.NextPage();
      preview.NextPage();

work.
Please see below code in the MainWindow constructor (all I did was add a single line to the existing code)... can anyone help with displaying a page other than the default first page?
Code:
  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();

      // Create a new MigraDoc document
      Document document = SampleDocuments.CreateSample1();

      // HACK
      string ddl = DdlWriter.WriteToString(document);
      preview.Ddl = ddl;

      preview.Page = 3;    // This newly entered line does not work !?!
    }
    ...
  }

Please help,
Thanks, Brad.

Author:  Thomas Hoevel [ Mon Dec 03, 2012 2:02 pm ]
Post subject:  Re: Can't navigate to a page in DocumentViewer !?!

Hi!

It's correct, the Page property has no effect with the WPF build of the document preview.

You can make the "viewer" element public and write something like this in the constructor:
Code:
string ddl = DdlWriter.WriteToString(document);
preview.Ddl = ddl;

preview.viewer.VerticalOffset = 1122 * 2;


You'll have to examine the code to find the correct offset for the 3rd page (see "GetSizeOfPage" in "DdlUpdated()").

To make the "viewer" public, change DocumentPreview.xaml like this:
Code:
<DocumentViewer x:Name="viewer" x:FieldModifier="public">
</DocumentViewer>

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/