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

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
Guest  
#1 Posted : Thursday, April 7, 2016 2:04:41 AM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 162

Was thanked: 5 time(s) in 5 post(s)
hi,

Is there a way when i click on a bookmark in my list of bookmarks to display the page who correspond (in a pdf who contains multiple pages) ?

thank you
Paul Rayman  
#2 Posted : Thursday, April 7, 2016 4:21:01 AM(UTC)
Quote
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)
Please look at bookmark's Action and Destination properties here: https://pdfium.patagames.com/help/html/39813c60-72f9-1565-4e1f-0de959822d66.htm

The destination contain the PageIndex property, so you may call PdfViewer.ScrollToPage(destination.PageIndex).

Code:

if (Bookmark.Action != null)
	ProcessAction(Bookmark.Action);
else if (Bookmark.Destination != null)
	ProcessDestination(Bookmark.Destination);

Code:

private void ProcessAction(PdfAction pdfAction)
{
	if (pdfAction.ActionType == ActionTypes.Uri)
		Process.Start(pdfAction.ActionUrl);
	else if (pdfAction.Destination != null)
		ProcessDestination(pdfAction.Destination);
}

Code:

private void ProcessDestination(PdfDestination pdfDestination)
{
	ScrollToPage(pdfDestination.PageIndex);
	Invalidate();
}

Edited by user Thursday, April 7, 2016 4:23:55 AM(UTC)  | Reason: Not specified

Guest  
#3 Posted : Friday, April 8, 2016 4:35:54 AM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 162

Was thanked: 5 time(s) in 5 post(s)
thanks and how can i get the action from the bookmarkviewer (node clicked on the treeview) ?
Paul Rayman  
#4 Posted : Friday, April 8, 2016 7:32:37 AM(UTC)
Quote
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)
Code:

_bookmarksViewer.AfterSelect += _bookmarksViewer_AfterSelect;


Code:

private void _bookmarksViewer_AfterSelect(object sender, TreeViewEventArgs e)
{
	var node = e.Node as BookmarksViewerNode;
	if (node == null || node.Bookmark == null)
		return;

	if (node.Bookmark.Action != null)
		ProcessAction(node.Bookmark.Action);
	else if (node.Bookmark.Destination != null)
		ProcessDestination(node.Bookmark.Destination);
}


BTW, you can do the following:
Code:

pdfViewer1.BookmarksViewer = bookmarksViewer1

that's all

Edited by user Friday, April 8, 2016 7:36:39 AM(UTC)  | Reason: Not specified

Guest  
#5 Posted : Wednesday, April 13, 2016 2:14:08 AM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 162

Was thanked: 5 time(s) in 5 post(s)
var node = e.Node as BookmarksViewerNode;

it seems to be not possible, visual studio says it's not possible because its level protection "bookmarksviewermode"

Edited by user Wednesday, April 13, 2016 2:30:36 AM(UTC)  | Reason: Not specified

Paul Rayman  
#6 Posted : Wednesday, April 13, 2016 3:30:37 AM(UTC)
Quote
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)
if you are using bookmark viewer provided by sdk then you need the following only

Code:

pdfViewer1.BookmarksViewer = bookmarksViewer1


PdfViewer implements the scroll to page on click on a bookmark functionality by default.

Edited by user Wednesday, April 13, 2016 3:33:26 AM(UTC)  | Reason: Not specified

Guest  
#7 Posted : Wednesday, April 13, 2016 3:50:03 AM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 162

Was thanked: 5 time(s) in 5 post(s)
OMG it works :D? THANKS
Guest  
#8 Posted : Monday, April 25, 2016 2:10:17 AM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 162

Was thanked: 5 time(s) in 5 post(s)
there is a way to do the same thing with wpf pdfviewer?
claudiu  
#9 Posted : Thursday, June 6, 2019 5:08:34 PM(UTC)
Quote
claudiu

Rank: Newbie

Groups: Registered
Joined: 6/6/2019(UTC)
Posts: 5
Canada

Thanks: 2 times
Hi there,

could you point me to an example on how to implement a bookmark viewer in WPF.

Cheers!
Paul Rayman  
#10 Posted : Friday, June 14, 2019 1:42:50 AM(UTC)
Quote
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)
BookmarksViewer code on WinForms is very simple. There are literally a few lines of code. Therefore, you can easily implement it in the WPF yourself, using any standard control suitable for your application. Source code can be found here: https://github.com/Patag...aster/BookmarksViewer.cs
Quick Reply Show Quick Reply
Users browsing this topic
Guest (3)
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.