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
lugangxyz  
#1 Posted : Thursday, October 15, 2020 8:07:25 AM(UTC)
Quote
lugangxyz

Rank: Newbie

Groups: Registered
Joined: 10/15/2020(UTC)
Posts: 8
China

Hi there
I need to create a bookmark which point to a external url
From what I learned so far, seems I need to create a pdfAction(with externl uri) for this
But then I found that with PdfBookmark I can not change the pdfaction propety directlly

So is there a way which I can create a bookmark(link to external pdf file) from pdfium net?

Thanks in advance

Edited by user Thursday, October 15, 2020 8:08:11 AM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Sunday, October 18, 2020 7:18:37 PM(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:

using(var doc = PdfDocument.CreateNew())
{
    var page = doc.Pages.InsertPageAt(0, 500, 500);

    //Create a file specification for the target document.
    var fileSpec = new PdfFileSpecification(doc);
    fileSpec.FileName = @"e:\0\1GB\test_big.pdf";

    //create destination in remote document
    var dest = new PdfDestination(doc);
    dest.IsSameDocument = false;
    dest.PageIndex = 99;

    //create a new bookmark (the bookmark will target the current document)
    var bookmark = doc.Bookmarks.InsertAt(0, "Title", page);

    //Create action dictionary
    var action = PdfTypeDictionary.Create();
    //Action type
    action["S"] = PdfTypeName.Create("GoToR");
    //file specification
    action["F"] = fileSpec.Dictionary;
    //destination in remote document
    action["D"] = PdfTypeArray.Create(dest.Handle);

    //set an action to a bookmark.
    bookmark.Dictionary["A"] = action;
    //remove the old destination from the bookmark.
    bookmark.Dictionary.Remove("Dest");

    doc.Save(@"e:\80\test.pdf", SaveFlags.NoIncremental);
}    

Edited by user Sunday, October 18, 2020 7:43:10 PM(UTC)  | Reason: Not specified

Quick Reply Show Quick Reply
Users browsing this topic
Guest
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.