0

Is this possible to open PDF file with exists Bookmarks on a specific one, programmatically on C# (It's OK for me to work with ItextSharp, if there a way)?

I followed this question and it's work for destination not for bookmarks.

Another alternative that could work for me is to configure destination with Word 2007, so after the converting to PDF with Acrobat reader the Destinations and their name will save.

Thanks for help!

EDIT 1

This is my code : (Click on button 1 write all the bookmarks to a combobox)

private void button1_Click(object sender, EventArgs e)
    {
        reader = new PdfReader("C:\\Users\\itay\\Desktop\\V-Sperm Gold 3.49 User Guide_04_APR_11.pdf");
        book_mark = SimpleBookmark.GetBookmark(reader);
        foreach (Dictionary<string, object> bk in book_mark)
        {
            foreach (KeyValuePair<string, object> kvr in bk)
            {
                if (kvr.Key == "Kids" || kvr.Key == "kids")
                {
                    IList<Dictionary<string, object>> child =
                            (IList<Dictionary<string, object>>)kvr.Value;

                    recursive_search(child, tn);

                }

                else if (kvr.Key == "Title" || kvr.Key == "title")
                {
                    tn = new System.Windows.Forms.TreeNode(kvr.Value.ToString());
                    //comboBox1.Items.Add(tn.Text);
                }
                else if (kvr.Key == "Page" || kvr.Key == "page")
                {
                    //saves page number
                    tn.ToolTipText = Regex.Match(kvr.Value.ToString(), "[0-9]+").Value;
                }
            }
        }

    }

    public void recursive_search(IList<Dictionary<string, object>> ilist, TreeNode tnt)
    {
        foreach (Dictionary<string, object> bk in ilist)
        {
            foreach (KeyValuePair<string, object> kvr in bk)
            {
                if (kvr.Key == "Kids" || kvr.Key == "kids")
                {
                    IList<Dictionary<string, object>> child =
                                (IList<Dictionary<string, object>>)kvr.Value;
                    recursive_search(child, tn);

                }
                else if (kvr.Key == "Title" || kvr.Key == "title")
                {
                    tn = new System.Windows.Forms.TreeNode(kvr.Value.ToString());
                    comboBox1.Items.Add(tn.Text);
                }
                else if (kvr.Key == "Page" || kvr.Key == "page")
                {
                    tn.ToolTipText = Regex.Match(kvr.Value.ToString(), "[0-9]+").Value;
                    tnt.Nodes.Add(tn);

                }
            }
        }
    }

Click on Button 2 open the PDF :

    private void button2_Click(object sender, EventArgs e)
    {
        Process myProcess = new Process();
        myProcess.StartInfo.FileName = "AcroRd32.exe";
        myProcess.StartInfo.Arguments = "pagemode=bookmarks&nameddest=" + comboBox1.Text + "\" \"" + "C:\\Users\\itay\\Desktop\\V-Sperm Gold 3.49 User Guide_04_APR_11.pdf" + "\"";
        myProcess.Start();
    }
Community
  • 1
  • 1
user2235615
  • 1,513
  • 3
  • 17
  • 37

1 Answers1

1

You seem to be looking for a specific Open Parameter and you can't find it, because you're looking for something that doesn't exist.

Please consult the official documentation that is available on Adobe's web site: http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf

There is no way to define a bookmark that can be triggered. You'll find open parameters such as nameddest (which you already knew) and page to jump to specific places in the PDF, but if you want to jump to a specific bookmark, you need to examine the bookmarks (for instance using the SimpleBookmark class. If you see that the bookmark points at a certain page, you need to use the page parameter and you can combine it with the zoom, view or viewrect parameter depending on the destination that is defined for that page.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165