Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Sun Mar 18, 2018 12:59 pm

Hello,

can you please tell me, how can I create a named destination inside my generated pdf? I need to be able to open the pdf at a specific named destination from URL or command line, e.g. using "AcroRd32.exe /A nameddest=MyDestination MyFile.pdf".

I didn't find any related information or class, so I tried it by creating PdfBookmark and PdfNamedAction, bookmark works but no luck with opening the document at the destination.

Thanks
Robert

rsojak
 
Posts: 3
Joined: Sun Mar 18, 2018 12:53 pm

Mon Mar 19, 2018 3:22 am

Dear Robert,

Thanks for your inquiry.
Please refer to below documentation to implement your need. If there is any question, welcome to get it back to us.
Create a GoToE Action to an Embedded PDF File

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Mon Mar 19, 2018 8:29 am

Hi Nina,

thanks for the link, but I believe that it is something different. I don't need to open an embedded pdf, I need to open my single pdf at a specified named destination (e.g. "Chapter 2.3") via url or command line, not by clicking inside the pdf.

This page describes the exact required funcionality: https://help.syncfusion.com/file-formats/pdf/working-with-named-destination

Thank you for the support,
Robert

rsojak
 
Posts: 3
Joined: Sun Mar 18, 2018 12:53 pm

Mon Mar 19, 2018 9:25 am

Hello,

Thanks for your detailed information.
Please refer to below sample code to accomplish your task.
Code: Select all
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add(); 
//Define a specific location
PdfDestination destination = new PdfDestination(page,new PointF(0,500));
PdfGoToAction action = new PdfGoToAction(destination);
//Set zoom factor
action.Destination.Zoom = 4.0f;
//Execute the action after opening the document
doc.AfterOpenAction = action;
//Draw the string
page.Canvas.DrawString("Hello World", new PdfTrueTypeFont(new Font("Arial", 12f), true), new PdfSolidBrush(Color.Blue), new PointF(0, 500));
//Save the PDF file
doc.SaveToFile("Result.pdf",FileFormat.PDF);


Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Mon Mar 19, 2018 1:37 pm

Dear Nina,

thanks for the code. It uses document's AfterOpenAction, to execute one singular action when the document is opened. The action is hardcoded to the pdf when it is rendered by the code. That's entirely different than my need.

If you can please look at the page I linked in the previous post as an example. It describes Named destinations inside a pdf, which are standard pdf document feature. You can create named destination for example for each chapter in the pdf, let's say Chapter1, Chapter2 and Chapter3. Then when someone opens the pdf as usual, nothing extraordinary happens. But, when the pdf is opened with the special string argument (via url od command line), the pdf viewer scrolls the document to the specified named destination, e.g. Chapter2. This is needed, when you're opening the pdf from another software/web page and you need to automatically scroll to the related section.

Maybe in SpirePDF this is not called Named destinations, but I didn't find how to create corresponding functionality. I tried the PdfDestination for that purpose, but I didn't find a way to name the destination (by a text or number) so it can be later specified in the opening argument. I hope it can be done somehow with Spire?

Best regards
Robert

rsojak
 
Posts: 3
Joined: Sun Mar 18, 2018 12:53 pm

Tue Mar 20, 2018 3:43 am

Dear Robert,

Sorry I misunderstood you earlier.
Now I get your meaning. But sorry the function of creating named destination is not supported in our Spire.Pdf at present. We will consider adding it into our upgrade list, and will keep you informed if it is achieved. One more thing, would you please provide a sample PDF file with us? That would be better to build the feature according to your sample file.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF