【发布时间】:2016-03-19 13:45:34
【问题描述】:
我正在尝试从包含比我需要的更多数据的树节点(至少我认为是这样)传输数据。我很难操作树节点中的数据。我更希望有一个数组,它只为我提供数据操作所需的数据。
我希望更高的利率具有以下变量: 1. BookmarkNumber(整数) 2.日期(字符串) 3. DocumentType(字符串) 4. BookmarkPageNumberString(字符串) 5. BookmarkPageNumberInteger(整数)
我想从变量 book_mark 的数据中得到上面定义的速率(如我的代码所示)。
我已经为此苦苦挣扎了两天。任何帮助将非常感激。我可能确定问题的措辞不正确,所以请提出问题,以便我在需要时进一步解释。
非常感谢
顺便说一句,我要做的是创建一个 Windows 窗体程序,该程序将具有多个书签的 PDF 文件解析为每个书签/章节的离散 PDF 文件,同时使用正确的命名约定将书签保存在正确的文件夹中,文件夹和命名约定取决于被解析的书签/章节的 PDF 名称和标题名称。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using itextsharp.pdfa;
using iTextSharp.awt;
using iTextSharp.testutils;
using iTextSharp.text;
using iTextSharp.xmp;
using iTextSharp.xtra;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void ChooseImageFileWrapper_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = GlobalVariables.InitialDirectory;
openFileDialog1.Filter = "Pdf Files|*.pdf";
openFileDialog1.RestoreDirectory = true;
openFileDialog1.Title = "Image File Wrapper Chooser";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
GlobalVariables.ImageFileWrapperPath = openFileDialog1.FileName;
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
ImageFileWrapperPath.Text = GlobalVariables.ImageFileWrapperPath;
}
private void ImageFileWrapperPath_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
iTextSharp.text.pdf.PdfReader pdfReader = new iTextSharp.text.pdf.PdfReader(GlobalVariables.ImageFileWrapperPath);
IList<Dictionary<string, object>> book_mark = iTextSharp.text.pdf.SimpleBookmark.GetBookmark(pdfReader);
List<ImageFileWrapperBookmarks> IFWBookmarks = new List<ImageFileWrapperBookmarks>();
foreach (Dictionary<string, object> bk in book_mark) // bk is a single instance of book_mark
{
ImageFileWrapperBookmarks.BookmarkNumber = ImageFileWrapperBookmarks.BookmarkNumber + 1;
foreach (KeyValuePair<string, object> kvr in bk) // kvr is the key/value in bk
{
if (kvr.Key == "Kids" || kvr.Key == "kids")
{
//create recursive program for children
}
else if (kvr.Key == "Title" || kvr.Key == "title")
{
}
else if (kvr.Key == "Page" || kvr.Key == "page")
{
}
}
}
MessageBox.Show(GlobalVariables.ImageFileWrapperPath);
}
}
}
【问题讨论】:
标签: c# arrays pdf tree itextsharp