Print Page | Close Window

Problem with SetOutlineNamedDestination

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2774
Printed Date: 25 Jan 26 at 7:19PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Problem with SetOutlineNamedDestination
Posted By: robbo969
Subject: Problem with SetOutlineNamedDestination
Date Posted: 06 Nov 13 at 11:06PM
Hi all,

I am trying to upgrade bookmarks to proper named destinations so I can link to them from a web page. I can step through the bookmarks and retrieve their IDs and names and then call to  SetOutlineNamedDestination(ID, Name) and I get the correct response 1 (= success) but when I try and read back the NamedDestinations or save the file they're lost.

Has anyone had experience with SetOutlineNamedDestination either good or bad. Am I missing a step to commit the information to the file before saving?

Regards,
Graeme



Replies:
Posted By: robbo969
Date Posted: 07 Nov 13 at 1:01PM
For info, the code looks like the attached and seems to complete with the correct responses...

            string strStartingFilename = @"C:\_Testing\v3_0\HTML\files\C\_Catalyst_Demos\__BidExample\Executive Summary\Executive Summary.pdf";
            string strFinalFilename    = @"C:\_Testing\v3_0\HTML\files\C\_Catalyst_Demos\__BidExample\Executive Summary\GRs_cSharp_Edit.pdf";
            string strKey              =  "xyz";
            

            DebenuPDFLibraryAX0911.PDFLibrary PDFLib = new DebenuPDFLibraryAX0911.PDFLibrary();

            //Unlock the library
            int InstanceID = PDFLib.UnlockKey(strKey);

            // Open the file
            int iLoadFile = PDFLib.LoadFromFile(strStartingFilename, "");

            // Now we need some readings from the file
            int docCount      = PDFLib.DocumentCount();
            int iAnnotations  = PDFLib.AnnotationCount();
            int iPages        = PDFLib.PageCount();
            int iOutlineCount = PDFLib.OutlineCount();

            string strReport = "";
            string BMName = "";
            int x;
            int iOutlineID;
            int iReturn;

            iOutlineID = PDFLib.GetOutlineID(3);

            BMName = PDFLib.OutlineTitle(iOutlineID);


            for ( x = 0; x < iOutlineCount; x++ ) 
            {

                PDFLib.SelectDocument(iLoadFile);

                iOutlineID = PDFLib.GetOutlineID(x);
 
                BMName = PDFLib.OutlineTitle(iOutlineID);

                if (BMName != "" && BMName != null) 
                {             
                    
                    strReport = strReport + ", " + BMName;


                    iReturn = PDFLib.SetOutlineNamedDestination(iOutlineID, BMName);
                    if (iReturn == 1)
                    {
                        MessageBox.Show("Created Destination '" + BMName + "'");
                        strReport = strReport + ", " + BMName;
                    }
                    else
                    {
                        MessageBox.Show("Can't create Destination '" + BMName + "'");
                    }
                }


            }


            MessageBox.Show( strReport);

            PDFLib.SaveToFile(strFinalFilename);


Posted By: Rowan
Date Posted: 11 Nov 13 at 5:15AM
Hi robbo969,

I've tested your code on my end and it appears to be working correctly with the slight issue that the for loop should be 'less than or equal to' so that it doesn't miss the last outline and it is not currently creating the new named destinations.

Here's a modification that creates the new named destinations before you set the outline to look for that named destination:

if (BMName != "" && BMName != null)
                {

                    strReport = strReport + ", " + BMName;

                    // Start mod: You need to create the named destination
                    // before you assign the outline to it

                    int iDestID = DPL.GetOutlineDest(iOutlineID);
                    DPL.NewNamedDestination(BMName, iDestID);                   

                    // Finish mod

                    iReturn = DPL.SetOutlineNamedDestination(iOutlineID, BMName);
                    if (iReturn == 1)
                    {
                        MessageBox.Show("Created Destination '" + BMName + "'");
                        strReport = strReport + ", " + BMName;
                    }
                    else
                    {
                        MessageBox.Show("Can't create Destination '" + BMName + "'");
                    }
                }

I hope this helps.

Cheers,
- Rowan.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk