【发布时间】:2014-06-22 13:23:01
【问题描述】:
这是否可以在 C# 上以编程方式在特定文件上打开带有书签的 PDF 文件(如果有办法,我可以使用 ItextSharp)?
我关注了this 问题,它适用于目的地而不是书签。
对我有用的另一种选择是使用 Word 2007 配置目标,因此在使用 Acrobat 阅读器转换为 PDF 后,目标及其名称将保存。
感谢您的帮助!
编辑 1
这是我的代码:(单击按钮 1 将所有书签写入组合框)
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);
}
}
}
}
点击按钮 2 打开 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();
}
【问题讨论】:
标签: c# pdf itextsharp word-2007