Commits

gb2013  committed de486a2

上传PDF抽取工具源码;

  • Participants

Comments (0)

Files changed (15)

+# Ignore file for Visual Studio 2008
+
+# use glob syntax
+syntax: glob
+
+# Ignore Visual Studio 2008 files
+*.obj
+*.exe
+*.pdb
+*.user
+*.msi
+*.aps
+*.pch
+*.vspscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.cache
+*.ilk
+*.log
+*.lib
+*.sbr
+*.scc
+*.sws
+*.pdsync
+*.pdsyncu
+~*.doc
+[Tt]humbs.db
+packages/
+[Bb]in*/
+[Dd]ebug*/
+[Ll]ogs/
+Backup/
+obj/
+[Rr]elease*/
+_ReSharper*/
+_UpgradeReport_Files/
+[Tt]est[Rr]esult*
+[Bb]uild[Ll]og.*
+*.[Pp]ublish.xml
+UpgradeLog.XML
+*.csproj.user
+*.ncb
+*.suo

File Assemblies/PdfSharp.dll

Binary file added.

File Assemblies/itextsharp.dll

Binary file added.

File PdfExtractor.sln

+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfExtractor", "PdfExtractor\PdfExtractor.csproj", "{A5905A5C-23CC-4808-8527-481EB5693878}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|x86 = Debug|x86
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{A5905A5C-23CC-4808-8527-481EB5693878}.Debug|x86.ActiveCfg = Debug|x86
+		{A5905A5C-23CC-4808-8527-481EB5693878}.Debug|x86.Build.0 = Debug|x86
+		{A5905A5C-23CC-4808-8527-481EB5693878}.Release|x86.ActiveCfg = Release|x86
+		{A5905A5C-23CC-4808-8527-481EB5693878}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

File PdfExtractor/CompatiblePdfReader.cs

+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using PdfSharp.Pdf;
+using PdfSharp.Pdf.IO;
+
+namespace PdfExtractor
+{
+    /// <summary>
+    /// uses itextsharp 5.3.0 to convert any pdf to 1.4 compatible pdf, called instead of PdfReader.open
+    /// </summary>
+    static public class CompatiblePdfReader
+    {
+        /// <summary>
+        /// uses itextsharp 5.3.0 to convert any pdf to 1.4 compatible pdf, called instead of PdfReader.open
+        /// </summary>
+        static public PdfDocument Open(string PdfPath, PdfDocumentOpenMode openmode)
+        {
+            using (FileStream fileStream = new FileStream(PdfPath, FileMode.Open, FileAccess.Read))
+            {
+                int len = (int)fileStream.Length;
+                Byte[] fileArray = new Byte[len];
+                fileStream.Read(fileArray, 0, len);
+                fileStream.Close();
+
+                return Open(fileArray, openmode);
+            }
+        }
+
+        /// <summary>
+        /// uses itextsharp 5.3.0 to convert any pdf to 1.4 compatible pdf, called instead of PdfReader.open
+        /// </summary>
+        static public PdfDocument Open(byte[] fileArray, PdfDocumentOpenMode openmode)
+        {
+            return Open(new MemoryStream(fileArray), openmode);
+        }
+
+        /// <summary>
+        /// uses itextsharp 5.3.0 to convert any pdf to 1.4 compatible pdf, called instead of PdfReader.open
+        /// </summary>
+        static public PdfDocument Open(MemoryStream sourceStream, PdfDocumentOpenMode openmode)
+        {
+            PdfDocument outDoc = null;
+            sourceStream.Position = 0;
+
+            try
+            {
+                outDoc = PdfReader.Open(sourceStream, openmode);
+            }
+            catch (PdfSharp.Pdf.IO.PdfReaderException)
+            {
+                //workaround if pdfsharp doesn't support this pdf
+                sourceStream.Position = 0;
+                MemoryStream outputStream = new MemoryStream();
+                iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(sourceStream);
+                iTextSharp.text.pdf.PdfStamper pdfStamper = new iTextSharp.text.pdf.PdfStamper(reader, outputStream);
+                pdfStamper.FormFlattening = true;
+                pdfStamper.Writer.SetPdfVersion(iTextSharp.text.pdf.PdfWriter.PDF_VERSION_1_4);
+                pdfStamper.Writer.CloseStream = false;
+                pdfStamper.Close();
+
+                outDoc = PdfReader.Open(outputStream, openmode);
+            }
+
+            return outDoc;
+        }
+    }
+}

File PdfExtractor/MainForm.Designer.cs

+namespace PdfExtractor
+{
+    partial class ExtractorMainForm
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.label1 = new System.Windows.Forms.Label();
+            this.rbtSingleFile = new System.Windows.Forms.RadioButton();
+            this.rbFolder = new System.Windows.Forms.RadioButton();
+            this.groupOptType = new System.Windows.Forms.GroupBox();
+            this.groupProcess = new System.Windows.Forms.GroupBox();
+            this.btnProcess = new System.Windows.Forms.Button();
+            this.btnBrowserFile = new System.Windows.Forms.Button();
+            this.label2 = new System.Windows.Forms.Label();
+            this.txtFileOrFolderPath = new System.Windows.Forms.TextBox();
+            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
+            this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
+            this.groupOptType.SuspendLayout();
+            this.groupProcess.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(42, 29);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(113, 12);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "请选择相应的操作:";
+            // 
+            // rbtSingleFile
+            // 
+            this.rbtSingleFile.AutoSize = true;
+            this.rbtSingleFile.Location = new System.Drawing.Point(190, 27);
+            this.rbtSingleFile.Name = "rbtSingleFile";
+            this.rbtSingleFile.Size = new System.Drawing.Size(95, 16);
+            this.rbtSingleFile.TabIndex = 1;
+            this.rbtSingleFile.TabStop = true;
+            this.rbtSingleFile.Text = "处理单个文件";
+            this.rbtSingleFile.UseVisualStyleBackColor = true;
+            // 
+            // rbFolder
+            // 
+            this.rbFolder.AutoSize = true;
+            this.rbFolder.Location = new System.Drawing.Point(320, 27);
+            this.rbFolder.Name = "rbFolder";
+            this.rbFolder.Size = new System.Drawing.Size(83, 16);
+            this.rbFolder.TabIndex = 2;
+            this.rbFolder.TabStop = true;
+            this.rbFolder.Text = "处理文件夹";
+            this.rbFolder.UseVisualStyleBackColor = true;
+            // 
+            // groupOptType
+            // 
+            this.groupOptType.Controls.Add(this.rbtSingleFile);
+            this.groupOptType.Controls.Add(this.label1);
+            this.groupOptType.Controls.Add(this.rbFolder);
+            this.groupOptType.Location = new System.Drawing.Point(52, 12);
+            this.groupOptType.Name = "groupOptType";
+            this.groupOptType.Size = new System.Drawing.Size(524, 73);
+            this.groupOptType.TabIndex = 3;
+            this.groupOptType.TabStop = false;
+            this.groupOptType.Text = "操作类型";
+            // 
+            // groupProcess
+            // 
+            this.groupProcess.Controls.Add(this.btnProcess);
+            this.groupProcess.Controls.Add(this.btnBrowserFile);
+            this.groupProcess.Controls.Add(this.label2);
+            this.groupProcess.Controls.Add(this.txtFileOrFolderPath);
+            this.groupProcess.Location = new System.Drawing.Point(52, 103);
+            this.groupProcess.Name = "groupProcess";
+            this.groupProcess.Size = new System.Drawing.Size(524, 230);
+            this.groupProcess.TabIndex = 4;
+            this.groupProcess.TabStop = false;
+            this.groupProcess.Text = "操作";
+            // 
+            // btnProcess
+            // 
+            this.btnProcess.Location = new System.Drawing.Point(200, 115);
+            this.btnProcess.Name = "btnProcess";
+            this.btnProcess.Size = new System.Drawing.Size(75, 23);
+            this.btnProcess.TabIndex = 3;
+            this.btnProcess.Text = "开始处理";
+            this.btnProcess.UseVisualStyleBackColor = true;
+            this.btnProcess.Click += new System.EventHandler(this.btnProcess_Click);
+            // 
+            // btnBrowserFile
+            // 
+            this.btnBrowserFile.Location = new System.Drawing.Point(410, 37);
+            this.btnBrowserFile.Name = "btnBrowserFile";
+            this.btnBrowserFile.Size = new System.Drawing.Size(75, 23);
+            this.btnBrowserFile.TabIndex = 2;
+            this.btnBrowserFile.Text = "浏览";
+            this.btnBrowserFile.UseVisualStyleBackColor = true;
+            this.btnBrowserFile.Click += new System.EventHandler(this.btnBrowserFile_Click);
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(40, 43);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(41, 12);
+            this.label2.TabIndex = 1;
+            this.label2.Text = "路径:";
+            // 
+            // txtFileOrFolderPath
+            // 
+            this.txtFileOrFolderPath.Location = new System.Drawing.Point(87, 40);
+            this.txtFileOrFolderPath.Name = "txtFileOrFolderPath";
+            this.txtFileOrFolderPath.Size = new System.Drawing.Size(316, 21);
+            this.txtFileOrFolderPath.TabIndex = 0;
+            // 
+            // openFileDialog1
+            // 
+            this.openFileDialog1.FileName = "openFileDialog1";
+            // 
+            // ExtractorMainForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(606, 399);
+            this.Controls.Add(this.groupProcess);
+            this.Controls.Add(this.groupOptType);
+            this.Name = "ExtractorMainForm";
+            this.Text = "PDF提取器";
+            this.groupOptType.ResumeLayout(false);
+            this.groupOptType.PerformLayout();
+            this.groupProcess.ResumeLayout(false);
+            this.groupProcess.PerformLayout();
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.RadioButton rbtSingleFile;
+        private System.Windows.Forms.RadioButton rbFolder;
+        private System.Windows.Forms.GroupBox groupOptType;
+        private System.Windows.Forms.GroupBox groupProcess;
+        private System.Windows.Forms.Button btnBrowserFile;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.TextBox txtFileOrFolderPath;
+        private System.Windows.Forms.Button btnProcess;
+        private System.Windows.Forms.OpenFileDialog openFileDialog1;
+        private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
+    }
+}
+

File PdfExtractor/MainForm.cs

+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using PdfSharp.Pdf;
+using PdfSharp.Pdf.IO;
+
+namespace PdfExtractor
+{
+    public partial class ExtractorMainForm : Form
+    {
+        public ExtractorMainForm()
+        {
+            InitializeComponent();
+        }
+
+        private void btnBrowserFile_Click(object sender, EventArgs e)
+        {
+            if (rbtSingleFile.Checked)
+            {
+                openFileDialog1.Filter = "Pdf files(*.pdf)|*.pdf|All files(*.*)|*.*";
+                if (openFileDialog1.ShowDialog() == DialogResult.OK)
+                {
+                    txtFileOrFolderPath.Text = openFileDialog1.FileName;
+                    txtFileOrFolderPath.Enabled = false;
+                }
+            }
+            else
+            {
+                if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
+                {
+                    txtFileOrFolderPath.Text = folderBrowserDialog1.SelectedPath;
+                    txtFileOrFolderPath.Enabled = false;
+                }
+            }
+        }
+
+        private void btnProcess_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                if (string.IsNullOrEmpty(txtFileOrFolderPath.Text))
+                {
+                    MessageBox.Show("请先选择要操作的文件或文件夹!");
+                    return;
+                }
+                int iPageCount = 16;
+                string strSuffix = "_16";
+                if (rbtSingleFile.Checked)
+                {
+                    string entireFileFullName = txtFileOrFolderPath.Text.Trim();
+                    this.ExtractPdfFile(entireFileFullName, iPageCount, strSuffix);
+                }
+                else
+                {
+                    string folderPath = txtFileOrFolderPath.Text.Trim();
+                    DirectoryInfo dirInfo = new DirectoryInfo(folderPath);
+                    this.ExtractPdfWithSubFolder(dirInfo, iPageCount, strSuffix);
+
+                }
+                MessageBox.Show("抽取完成!");
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(string.Format("抽取PDF文件发生异常,异常信息:{0} 堆栈信息:{1}", ex.Message, ex.StackTrace));
+            }
+        }
+
+        /// <summary>
+        /// 从原文件抽取指定页数生成新的PDF文件
+        /// </summary>
+        /// <param name="fileFullName"></param>
+        /// <param name="pageCount"></param>
+        /// <param name="suffix"></param>
+        private void ExtractPdfFile(string fileFullName, int pageCount, string suffix)
+        {
+            try
+            {
+                PdfDocument entirePdfFile = CompatiblePdfReader.Open(fileFullName, PdfDocumentOpenMode.Import);
+                string smallFileFullName = fileFullName.Insert(fileFullName.LastIndexOf('.'), suffix);
+                PdfDocument smallPdfFile = new PdfDocument();
+                smallPdfFile.Version = entirePdfFile.Version;
+                smallPdfFile.Info.Title = entirePdfFile.Info.Title;
+                smallPdfFile.Info.Creator = entirePdfFile.Info.Creator;
+                int iCount = pageCount;
+                if (entirePdfFile.PageCount < iCount)
+                {
+                    iCount = entirePdfFile.PageCount;
+                }
+                for (int i = 0; i < iCount; i++)
+                {
+                    smallPdfFile.AddPage(entirePdfFile.Pages[i]);
+                }
+                smallPdfFile.Save(smallFileFullName);
+            }
+            catch (Exception ex)
+            {
+
+            }
+        }
+
+        private void ExtractPdfWithSubFolder(DirectoryInfo dirInfo, int pageCount, string suffix)
+        {
+            DirectoryInfo[] subDirArr = dirInfo.GetDirectories();
+            if (subDirArr.Length > 0)
+            {
+                foreach (var directoryInfo in subDirArr)
+                {
+                    this.ExtractPdfWithSubFolder(directoryInfo, pageCount, suffix);
+                }
+            }
+            FileInfo[] fiArr = dirInfo.GetFiles("*.pdf");
+            foreach (var fileInfo in fiArr)
+            {
+                string fileName = fileInfo.Name;
+                if (fileName.Substring(fileName.LastIndexOf('.') - 3, 3).Equals("_16"))
+                {
+                    continue;
+                }
+                this.ExtractPdfFile(fileInfo.FullName, pageCount, suffix);
+            }
+        }
+    }
+}

File PdfExtractor/MainForm.resx

+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>165, 17</value>
+  </metadata>
+</root>

File PdfExtractor/PdfExtractor.csproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A5905A5C-23CC-4808-8527-481EB5693878}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>PdfExtractor</RootNamespace>
+    <AssemblyName>PdfExtractor</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="itextsharp">
+      <HintPath>..\Assemblies\itextsharp.dll</HintPath>
+    </Reference>
+    <Reference Include="PdfSharp">
+      <HintPath>..\Assemblies\PdfSharp.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompatiblePdfReader.cs" />
+    <Compile Include="MainForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="MainForm.Designer.cs">
+      <DependentUpon>MainForm.cs</DependentUpon>
+    </Compile>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="MainForm.resx">
+      <DependentUpon>MainForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

File PdfExtractor/Program.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace PdfExtractor
+{
+    static class Program
+    {
+        /// <summary>
+        /// 应用程序的主入口点。
+        /// </summary>
+        [STAThread]
+        static void Main()
+        {
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            Application.Run(new ExtractorMainForm());
+        }
+    }
+}

File PdfExtractor/Properties/AssemblyInfo.cs

+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("PdfExtractor")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("PdfExtractor")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("9e05cd9a-fa98-4364-ae8b-7e7afbbdc5f4")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      内部版本号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

File PdfExtractor/Properties/Resources.Designer.cs

+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本: 4.0.30319.17929
+//
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace PdfExtractor.Properties
+{
+
+
+    /// <summary>
+    ///   一个强类型的资源类,用于查找本地化的字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources
+    {
+
+        private static global::System.Resources.ResourceManager resourceMan;
+
+        private static global::System.Globalization.CultureInfo resourceCulture;
+
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources()
+        {
+        }
+
+        /// <summary>
+        ///   返回此类使用的、缓存的 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if ((resourceMan == null))
+                {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PdfExtractor.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+
+        /// <summary>
+        ///   为所有资源查找重写当前线程的 CurrentUICulture 属性,
+        ///   方法是使用此强类型资源类。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
+                return resourceCulture;
+            }
+            set
+            {
+                resourceCulture = value;
+            }
+        }
+    }
+}

File PdfExtractor/Properties/Resources.resx

+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

File PdfExtractor/Properties/Settings.Designer.cs

+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.17929
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace PdfExtractor.Properties
+{
+
+
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+    {
+
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+        public static Settings Default
+        {
+            get
+            {
+                return defaultInstance;
+            }
+        }
+    }
+}

File PdfExtractor/Properties/Settings.settings

+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>