PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jul 01, 2024 11:17 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Dec 02, 2012 12:56 pm 
Offline

Joined: Sun Nov 18, 2012 8:35 am
Posts: 3
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 03, 2012 2:02 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
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>

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group