logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
bcpletcher  
#1 Posted : Friday, September 15, 2017 10:11:28 AM(UTC)
bcpletcher

Rank: Newbie

Groups: Registered
Joined: 7/21/2017(UTC)
Posts: 5
United States
Location: Michigan

Thanks: 1 times
My primary goal is to have two PDF viewers; one being a thumbnail viewer and the second one being the primary page viewer. I have successfully gotten both viewers to display the document but am confused on how to get them to interact with one another.

I would ideally like to click on a thumbnail in the left panel and bring that page to focus in the viewer panel. Is this at all possible and if so could someone please provide some code example to link the two viewers?

Thank you for your time and help!
Paul Rayman  
#2 Posted : Saturday, September 16, 2017 2:41:26 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Well...

XAML:
Code:

<ScrollViewer Grid.Row="1" Grid.Column="0" CanContentScroll="True"  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
    <Wpf:PdfViewer Name="pdfViewerThumbnails" 
        ViewMode="Vertical"
        MouseMode="None"
        RenderFlags="FPDF_HQTHUMBNAIL"
        CurrentPageChanged="pdfViewerThumbnails_CurrentPageChanged"/>
</ScrollViewer>

<ScrollViewer Grid.Row="1" Grid.Column="1" CanContentScroll="True"  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
    <Wpf:PdfViewer Name="pdfViewerPrimary" CurrentPageChanged="pdfViewerPrimary_CurrentPageChanged" />
</ScrollViewer>



Code behind:
Code:


PdfCommon.Initialize();
...
pdfViewerThumbnails.LoadDocument(@"d:\1\Pdfium.Net SDK - EULA.pdf");
pdfViewerPrimary.LoadDocument(@"d:\1\Pdfium.Net SDK - EULA.pdf");
...

private void pdfViewerThumbnails_CurrentPageChanged(object sender, EventArgs e)
{
	try
	{
		pdfViewerPrimary.CurrentPageChanged -= pdfViewerPrimary_CurrentPageChanged;
		pdfViewerPrimary.ScrollToPage(pdfViewerThumbnails.CurrentIndex);
		pdfViewerPrimary.CurrentIndex = pdfViewerThumbnails.CurrentIndex;
	}
	finally
	{
		pdfViewerPrimary.CurrentPageChanged += pdfViewerPrimary_CurrentPageChanged;
	}

}

private void pdfViewerPrimary_CurrentPageChanged(object sender, EventArgs e)
{
	try
	{
		pdfViewerThumbnails.CurrentPageChanged -= pdfViewerThumbnails_CurrentPageChanged;
		pdfViewerThumbnails.ScrollToPage(pdfViewerPrimary.CurrentIndex);
		pdfViewerThumbnails.CurrentIndex = pdfViewerPrimary.CurrentIndex;
	}
	finally
	{
		pdfViewerThumbnails.CurrentPageChanged += pdfViewerThumbnails_CurrentPageChanged;
	}
}
thanks 1 user thanked Paul Rayman for this useful post.
bcpletcher on 9/18/2017(UTC)
bcpletcher  
#3 Posted : Saturday, September 16, 2017 5:22:18 AM(UTC)
bcpletcher

Rank: Newbie

Groups: Registered
Joined: 7/21/2017(UTC)
Posts: 5
United States
Location: Michigan

Thanks: 1 times
Thank you so much for your fast response! I will try thing first thing on Monday and let you know the results!
bcpletcher  
#4 Posted : Monday, September 18, 2017 6:47:04 AM(UTC)
bcpletcher

Rank: Newbie

Groups: Registered
Joined: 7/21/2017(UTC)
Posts: 5
United States
Location: Michigan

Thanks: 1 times
This is extremely close to what i desire, however after playing with it i am trying to make a slight change but am struggling at how to accomplish it. I would like to be able to scroll on both (which it does currently) however only change the page when scrolled on the primary viewer but when a user clicks on a thumbnail it will load into that page in the primary.

Currently if scrolled through the thumbnails it will load the top most thumbnail.

Thanks again for all your help!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.