Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 58a0947364 | |||
| c43518adf9 | |||
| 668b816810 | |||
| 98a6b8e746 | |||
| a46bf67f81 | |||
| 6faf2d0fbe | |||
| 70c6272113 | |||
| 3108d03a75 | |||
| c651a22209 | |||
| f946a1bc1a | |||
| cfd8c37ab8 | |||
| d5d843014a | |||
| b9750745bc | |||
| c8c7e32acc | |||
| 781f212289 | |||
| 8a966049f6 | |||
| 80ab9b9ff3 | |||
| 9af363529c | |||
| 386b38bd21 | |||
| 53d07db9c0 | |||
| 9bc7854b48 | |||
| 77a5cd1b0e | |||
| b6611b6285 | |||
| 7badc8e4b1 | |||
| 203f30e55c | |||
| c3967dd439 | |||
| da8b512c1b | |||
| beb3b931ea | |||
| 8806020036 | |||
| f3b7cd1b0d | |||
| 33f9723ac6 | |||
| 13ba41f851 | |||
| 06de734658 | |||
| 901d7e62ca | |||
| 631f8c34b2 | |||
| 7ac6b19331 | |||
| 34e7424273 | |||
| 6b8bbc367f | |||
| 6dfc248b9a | |||
| f3aca2ffa5 | |||
| 7ba320a22c | |||
| 1edddf17b1 | |||
| 62120898d2 | |||
| dc1b9bc7ca | |||
| d1ea41474b | |||
| b11a2ac393 | |||
| 36fb20eb2e | |||
| 15fbec2470 | |||
| 52841de51b | |||
| d4c4615684 | |||
| ae76cab45d | |||
| 8dc54105fd | |||
| 3469593a2a | |||
| ebff0c2028 | |||
| 2fd074e041 | |||
| 4223619802 | |||
| 771305f5d0 | |||
| 90c7c5db92 | |||
| b474fc1257 | |||
| a5879ec9c2 | |||
| 0938553510 | |||
| c1fd18f355 | |||
| c0a8de2617 | |||
| 4d92f144f8 | |||
| c388e9daae | |||
| 29e49546fa | |||
| d46f8d2abe | |||
| 7d9b7981a8 | |||
| 9b2310ea96 | |||
| 58c09c1110 | |||
| 241b68bd0a | |||
| 85d998a8d3 | |||
| da908d0f36 | |||
| ed03166f6f | |||
| 17001d6c8a | |||
| 35ec8b478f |
27
.gitignore
vendored
27
.gitignore
vendored
@@ -1,27 +0,0 @@
|
||||
#ignorar miniaturas creadas por windows
|
||||
Thumbs.db
|
||||
#Ignorar archivos construidos por Visual Studio
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.lib
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
21
LICENSE.txt
21
LICENSE.txt
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2015 Valeriano Alfonso Rodriguez
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="VAR.PdfTools.Workbench.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
<userSettings>
|
||||
<VAR.PdfTools.Workbench.Properties.Settings>
|
||||
<setting name="LastPdfPath" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="LastColumnName" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="LastFieldName" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</VAR.PdfTools.Workbench.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
180
VAR.PdfTools.Workbench/FrmPdfInfo.Designer.cs
generated
180
VAR.PdfTools.Workbench/FrmPdfInfo.Designer.cs
generated
@@ -1,180 +0,0 @@
|
||||
namespace VAR.PdfTools.Workbench
|
||||
{
|
||||
partial class FrmPdfInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lblOutputs = new System.Windows.Forms.Label();
|
||||
this.lblInputs = new System.Windows.Forms.Label();
|
||||
this.btnBrowse = new System.Windows.Forms.Button();
|
||||
this.txtPdfPath = new System.Windows.Forms.TextBox();
|
||||
this.txtOutput = new System.Windows.Forms.TextBox();
|
||||
this.btnProcess = new System.Windows.Forms.Button();
|
||||
this.btnGetColumn = new System.Windows.Forms.Button();
|
||||
this.txtColumnName = new System.Windows.Forms.TextBox();
|
||||
this.txtFieldName = new System.Windows.Forms.TextBox();
|
||||
this.btnGetField = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lblOutputs
|
||||
//
|
||||
this.lblOutputs.AutoSize = true;
|
||||
this.lblOutputs.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblOutputs.Location = new System.Drawing.Point(12, 130);
|
||||
this.lblOutputs.Name = "lblOutputs";
|
||||
this.lblOutputs.Size = new System.Drawing.Size(51, 13);
|
||||
this.lblOutputs.TabIndex = 11;
|
||||
this.lblOutputs.Text = "Outputs";
|
||||
//
|
||||
// lblInputs
|
||||
//
|
||||
this.lblInputs.AutoSize = true;
|
||||
this.lblInputs.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblInputs.Location = new System.Drawing.Point(12, 9);
|
||||
this.lblInputs.Name = "lblInputs";
|
||||
this.lblInputs.Size = new System.Drawing.Size(42, 13);
|
||||
this.lblInputs.TabIndex = 10;
|
||||
this.lblInputs.Text = "Inputs";
|
||||
//
|
||||
// btnBrowse
|
||||
//
|
||||
this.btnBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnBrowse.Location = new System.Drawing.Point(316, 23);
|
||||
this.btnBrowse.Name = "btnBrowse";
|
||||
this.btnBrowse.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnBrowse.TabIndex = 9;
|
||||
this.btnBrowse.Text = "Browse";
|
||||
this.btnBrowse.UseVisualStyleBackColor = true;
|
||||
this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);
|
||||
//
|
||||
// txtPdfPath
|
||||
//
|
||||
this.txtPdfPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtPdfPath.Location = new System.Drawing.Point(15, 25);
|
||||
this.txtPdfPath.Name = "txtPdfPath";
|
||||
this.txtPdfPath.Size = new System.Drawing.Size(295, 20);
|
||||
this.txtPdfPath.TabIndex = 8;
|
||||
//
|
||||
// txtOutput
|
||||
//
|
||||
this.txtOutput.AcceptsReturn = true;
|
||||
this.txtOutput.AcceptsTab = true;
|
||||
this.txtOutput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtOutput.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txtOutput.Location = new System.Drawing.Point(15, 146);
|
||||
this.txtOutput.Multiline = true;
|
||||
this.txtOutput.Name = "txtOutput";
|
||||
this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.txtOutput.Size = new System.Drawing.Size(457, 303);
|
||||
this.txtOutput.TabIndex = 7;
|
||||
//
|
||||
// btnProcess
|
||||
//
|
||||
this.btnProcess.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnProcess.Location = new System.Drawing.Point(397, 23);
|
||||
this.btnProcess.Name = "btnProcess";
|
||||
this.btnProcess.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnProcess.TabIndex = 6;
|
||||
this.btnProcess.Text = "Process";
|
||||
this.btnProcess.UseVisualStyleBackColor = true;
|
||||
this.btnProcess.Click += new System.EventHandler(this.btnProcess_Click);
|
||||
//
|
||||
// btnGetColumn
|
||||
//
|
||||
this.btnGetColumn.Location = new System.Drawing.Point(163, 51);
|
||||
this.btnGetColumn.Name = "btnGetColumn";
|
||||
this.btnGetColumn.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnGetColumn.TabIndex = 12;
|
||||
this.btnGetColumn.Text = "GetColumn";
|
||||
this.btnGetColumn.UseVisualStyleBackColor = true;
|
||||
this.btnGetColumn.Click += new System.EventHandler(this.btnGetColumn_Click);
|
||||
//
|
||||
// txtColumnName
|
||||
//
|
||||
this.txtColumnName.Location = new System.Drawing.Point(15, 53);
|
||||
this.txtColumnName.Name = "txtColumnName";
|
||||
this.txtColumnName.Size = new System.Drawing.Size(142, 20);
|
||||
this.txtColumnName.TabIndex = 13;
|
||||
//
|
||||
// txtFieldName
|
||||
//
|
||||
this.txtFieldName.Location = new System.Drawing.Point(15, 82);
|
||||
this.txtFieldName.Name = "txtFieldName";
|
||||
this.txtFieldName.Size = new System.Drawing.Size(142, 20);
|
||||
this.txtFieldName.TabIndex = 15;
|
||||
//
|
||||
// btnGetField
|
||||
//
|
||||
this.btnGetField.Location = new System.Drawing.Point(163, 80);
|
||||
this.btnGetField.Name = "btnGetField";
|
||||
this.btnGetField.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnGetField.TabIndex = 14;
|
||||
this.btnGetField.Text = "GetField";
|
||||
this.btnGetField.UseVisualStyleBackColor = true;
|
||||
this.btnGetField.Click += new System.EventHandler(this.btnGetField_Click);
|
||||
//
|
||||
// FrmPdfInfo
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(484, 461);
|
||||
this.Controls.Add(this.txtFieldName);
|
||||
this.Controls.Add(this.btnGetField);
|
||||
this.Controls.Add(this.txtColumnName);
|
||||
this.Controls.Add(this.btnGetColumn);
|
||||
this.Controls.Add(this.lblOutputs);
|
||||
this.Controls.Add(this.lblInputs);
|
||||
this.Controls.Add(this.btnBrowse);
|
||||
this.Controls.Add(this.txtPdfPath);
|
||||
this.Controls.Add(this.txtOutput);
|
||||
this.Controls.Add(this.btnProcess);
|
||||
this.Name = "FrmPdfInfo";
|
||||
this.Text = "PdfInfo";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmPdfInfo_FormClosing);
|
||||
this.Load += new System.EventHandler(this.FrmPdfInfo_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label lblOutputs;
|
||||
private System.Windows.Forms.Label lblInputs;
|
||||
private System.Windows.Forms.Button btnBrowse;
|
||||
private System.Windows.Forms.TextBox txtPdfPath;
|
||||
private System.Windows.Forms.TextBox txtOutput;
|
||||
private System.Windows.Forms.Button btnProcess;
|
||||
private System.Windows.Forms.Button btnGetColumn;
|
||||
private System.Windows.Forms.TextBox txtColumnName;
|
||||
private System.Windows.Forms.TextBox txtFieldName;
|
||||
private System.Windows.Forms.Button btnGetField;
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VAR.PdfTools.Workbench
|
||||
{
|
||||
public partial class FrmPdfInfo : Form
|
||||
{
|
||||
public FrmPdfInfo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void FrmPdfInfo_Load(object sender, EventArgs e)
|
||||
{
|
||||
txtPdfPath.Text = Properties.Settings.Default.LastPdfPath;
|
||||
txtColumnName.Text = Properties.Settings.Default.LastColumnName;
|
||||
txtFieldName.Text = Properties.Settings.Default.LastFieldName;
|
||||
}
|
||||
|
||||
private void FrmPdfInfo_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
Properties.Settings.Default.LastPdfPath = txtPdfPath.Text;
|
||||
Properties.Settings.Default.LastColumnName = txtColumnName.Text;
|
||||
Properties.Settings.Default.LastFieldName = txtFieldName.Text;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
private void btnBrowse_Click(object sender, EventArgs e)
|
||||
{
|
||||
var dlgFile = new OpenFileDialog();
|
||||
DialogResult result = dlgFile.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
txtPdfPath.Text = dlgFile.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnProcess_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (System.IO.File.Exists(txtPdfPath.Text) == false)
|
||||
{
|
||||
MessageBox.Show("File does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
PdfDocument doc = PdfDocument.Load(txtPdfPath.Text);
|
||||
|
||||
int nObjects = doc.Objects.Count;
|
||||
int nRootObject = doc.Objects.Where(obj => obj.UsageCount == 0).Count();
|
||||
List<PdfStream> streams = doc.Objects
|
||||
.Where(obj => obj.Data.Type == PdfElementTypes.Stream)
|
||||
.Select(obj => (PdfStream)obj.Data)
|
||||
.ToList();
|
||||
int nStreams = streams.Count;
|
||||
int nPages = doc.Pages.Count;
|
||||
|
||||
List<string> lines = new List<string>();
|
||||
lines.Add(string.Format("Filename : {0}", System.IO.Path.GetFileNameWithoutExtension(txtPdfPath.Text)));
|
||||
lines.Add(string.Format("Number of Objects : {0}", nObjects));
|
||||
lines.Add(string.Format("Number of Roots : {0}", nRootObject));
|
||||
lines.Add(string.Format("Number of Streams : {0}", nStreams));
|
||||
lines.Add(string.Format("Number of Pages : {0}", nPages));
|
||||
|
||||
int pageNumber = 1;
|
||||
foreach (PdfDocumentPage page in doc.Pages)
|
||||
{
|
||||
lines.Add("-----------------------------------------------------------------------------------------");
|
||||
if (page.BaseData.Values.ContainsKey("CropBox"))
|
||||
{
|
||||
PdfArray cropBox = page.BaseData.Values["CropBox"] as PdfArray;
|
||||
lines.Add(string.Format("Page({0} of {1}): {2} {3} {4} {5}", pageNumber, doc.Pages.Count,
|
||||
PdfElementUtils.GetReal(cropBox.Values[0], 0),
|
||||
PdfElementUtils.GetReal(cropBox.Values[1], 0),
|
||||
PdfElementUtils.GetReal(cropBox.Values[2], 0),
|
||||
PdfElementUtils.GetReal(cropBox.Values[3], 0)));
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.Add(string.Format("Page({0} of {1}): ", pageNumber, doc.Pages.Count));
|
||||
}
|
||||
pageNumber++;
|
||||
|
||||
PdfTextExtractor extractor = new PdfTextExtractor(page);
|
||||
foreach (PdfTextElement textElement in extractor.Elements)
|
||||
{
|
||||
lines.Add(string.Format("Text({0}, {1})({2}, {3}): \"{4}\"",
|
||||
textElement.Matrix.Matrix[0, 2], textElement.Matrix.Matrix[1, 2], textElement.VisibleWidth, textElement.VisibleHeight,
|
||||
textElement.VisibleText));
|
||||
}
|
||||
}
|
||||
|
||||
txtOutput.Lines = lines.ToArray();
|
||||
}
|
||||
|
||||
private void btnGetColumn_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (System.IO.File.Exists(txtPdfPath.Text) == false)
|
||||
{
|
||||
MessageBox.Show("File does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
PdfDocument doc = PdfDocument.Load(txtPdfPath.Text);
|
||||
|
||||
var columnData = new List<string>();
|
||||
foreach (PdfDocumentPage page in doc.Pages)
|
||||
{
|
||||
PdfTextExtractor extractor = new PdfTextExtractor(page);
|
||||
columnData.AddRange(extractor.GetColumn(txtColumnName.Text));
|
||||
}
|
||||
txtOutput.Lines = columnData.ToArray();
|
||||
}
|
||||
|
||||
private void btnGetField_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (System.IO.File.Exists(txtPdfPath.Text) == false)
|
||||
{
|
||||
MessageBox.Show("File does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
PdfDocument doc = PdfDocument.Load(txtPdfPath.Text);
|
||||
|
||||
var fieldData = new List<string>();
|
||||
foreach (PdfDocumentPage page in doc.Pages)
|
||||
{
|
||||
PdfTextExtractor extractor = new PdfTextExtractor(page);
|
||||
fieldData.Add(extractor.GetField(txtFieldName.Text));
|
||||
}
|
||||
txtOutput.Lines = fieldData.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VAR.PdfTools.Workbench
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new FrmPdfInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("VAR.PdfTools.Workbench")]
|
||||
[assembly: AssemblyDescription("PdfTools Workbench")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("VAR")]
|
||||
[assembly: AssemblyProduct("VAR.PdfTools.Workbench")]
|
||||
[assembly: AssemblyCopyright("Copyright © VAR 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("a5825d8e-9f81-49e0-b610-8ae5e46d02ea")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
@@ -1,71 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace VAR.PdfTools.Workbench.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[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>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </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("VAR.PdfTools.Workbench.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,62 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace VAR.PdfTools.Workbench.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.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;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string LastPdfPath {
|
||||
get {
|
||||
return ((string)(this["LastPdfPath"]));
|
||||
}
|
||||
set {
|
||||
this["LastPdfPath"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string LastColumnName {
|
||||
get {
|
||||
return ((string)(this["LastColumnName"]));
|
||||
}
|
||||
set {
|
||||
this["LastColumnName"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string LastFieldName {
|
||||
get {
|
||||
return ((string)(this["LastFieldName"]));
|
||||
}
|
||||
set {
|
||||
this["LastFieldName"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="VAR.PdfTools.Workbench.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="LastPdfPath" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="LastColumnName" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="LastFieldName" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -1,99 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A5825D8E-9F81-49E0-B610-8AE5E46D02EA}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>VAR.PdfTools.Workbench</RootNamespace>
|
||||
<AssemblyName>VAR.PdfTools.Workbench</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</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|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FrmPdfInfo.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FrmPdfInfo.Designer.cs">
|
||||
<DependentUpon>FrmPdfInfo.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="FrmPdfInfo.resx">
|
||||
<DependentUpon>FrmPdfInfo.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>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VAR.PdfTools\VAR.PdfTools.csproj">
|
||||
<Project>{eb7e003a-6a95-4002-809f-926c7c8a11e9}</Project>
|
||||
<Name>VAR.PdfTools</Name>
|
||||
</ProjectReference>
|
||||
</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>
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VAR.PdfTools", "VAR.PdfTools\VAR.PdfTools.csproj", "{EB7E003A-6A95-4002-809F-926C7C8A11E9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VAR.PdfTools.Workbench", "VAR.PdfTools.Workbench\VAR.PdfTools.Workbench.csproj", "{A5825D8E-9F81-49E0-B610-8AE5E46D02EA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EB7E003A-6A95-4002-809F-926C7C8A11E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EB7E003A-6A95-4002-809F-926C7C8A11E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EB7E003A-6A95-4002-809F-926C7C8A11E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EB7E003A-6A95-4002-809F-926C7C8A11E9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A5825D8E-9F81-49E0-B610-8AE5E46D02EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A5825D8E-9F81-49E0-B610-8AE5E46D02EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A5825D8E-9F81-49E0-B610-8AE5E46D02EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A5825D8E-9F81-49E0-B610-8AE5E46D02EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,33 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VAR.PdfTools
|
||||
{
|
||||
public class PdfContentAction
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
string _token = null;
|
||||
|
||||
private List<IPdfElement> _parameters = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public string Token { get { return _token; } }
|
||||
|
||||
public List<IPdfElement> Parameters { get { return _parameters; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Life cycle
|
||||
|
||||
public PdfContentAction(string token, List<IPdfElement> parameters)
|
||||
{
|
||||
_token = token;
|
||||
_parameters = parameters;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,306 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
|
||||
namespace VAR.PdfTools
|
||||
{
|
||||
public class PdfDocument
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private List<PdfObject> _objects = new List<PdfObject>();
|
||||
|
||||
private PdfDictionary _catalog = null;
|
||||
|
||||
private List<PdfDocumentPage> _pages = new List<PdfDocumentPage>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public List<PdfObject> Objects { get { return _objects; } }
|
||||
|
||||
public PdfDictionary Catalog { get { return _catalog; } }
|
||||
|
||||
public List<PdfDocumentPage> Pages { get { return _pages; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Life cycle
|
||||
|
||||
private PdfDocument() { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
|
||||
private static byte[] DecodeFlateStreamData(byte[] streamData)
|
||||
{
|
||||
MemoryStream msInput = new MemoryStream(streamData);
|
||||
MemoryStream msOutput = new MemoryStream();
|
||||
|
||||
// It seems to work when skipping the first two bytes.
|
||||
byte header;
|
||||
header = (byte)msInput.ReadByte();
|
||||
header = (byte)msInput.ReadByte();
|
||||
|
||||
DeflateStream zip = new DeflateStream(msInput, CompressionMode.Decompress, true);
|
||||
int cbRead;
|
||||
byte[] abResult = new byte[1024];
|
||||
do
|
||||
{
|
||||
cbRead = zip.Read(abResult, 0, abResult.Length);
|
||||
if (cbRead > 0)
|
||||
{
|
||||
msOutput.Write(abResult, 0, cbRead);
|
||||
}
|
||||
}
|
||||
while (cbRead > 0);
|
||||
zip.Close();
|
||||
msOutput.Flush();
|
||||
if (msOutput.Length >= 0)
|
||||
{
|
||||
msOutput.Capacity = (int)msOutput.Length;
|
||||
return msOutput.GetBuffer();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void ApplyFiltersToStreams(PdfStream stream)
|
||||
{
|
||||
string filter = stream.Dictionary.GetParamAsString("Filter");
|
||||
if (filter == "FlateDecode")
|
||||
{
|
||||
stream.OriginalData = stream.Data;
|
||||
stream.OriginalFilter = stream.Dictionary.Values["Filter"];
|
||||
byte[] decodedStreamData = DecodeFlateStreamData(stream.Data);
|
||||
stream.Data = decodedStreamData;
|
||||
stream.Dictionary.Values["Length"] = new PdfInteger { Value = decodedStreamData.Length };
|
||||
stream.Dictionary.Values.Remove("Filter");
|
||||
}
|
||||
else if(filter == "ASCII85Decode" || filter == "A85")
|
||||
{
|
||||
// FIXME: Implement this filter
|
||||
}
|
||||
else if (filter == "CCITTFaxDecode")
|
||||
{
|
||||
// FIXME: Implement this filter
|
||||
}
|
||||
else if (filter == "DCTDecode")
|
||||
{
|
||||
// FIXME: Implement this filter
|
||||
}
|
||||
{
|
||||
// FIXME: Implement the rest of filters
|
||||
}
|
||||
}
|
||||
|
||||
private static IPdfElement ResolveIndirectReferences(IPdfElement elem, Dictionary<int, PdfObject> dictReferences)
|
||||
{
|
||||
if (elem is PdfObjectReference)
|
||||
{
|
||||
int objectId = ((PdfObjectReference)elem).ObjectID;
|
||||
if (dictReferences.ContainsKey(objectId))
|
||||
{
|
||||
PdfObject referencedObject = dictReferences[objectId];
|
||||
referencedObject.UsageCount++;
|
||||
return referencedObject.Data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new PdfNull();
|
||||
}
|
||||
}
|
||||
|
||||
PdfObject obj = elem as PdfObject;
|
||||
if (obj != null)
|
||||
{
|
||||
IPdfElement result = ResolveIndirectReferences(obj.Data, dictReferences);
|
||||
if (result != obj.Data)
|
||||
{
|
||||
obj.Data = result;
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
PdfArray array = elem as PdfArray;
|
||||
if (array != null)
|
||||
{
|
||||
for (int i = 0; i < array.Values.Count; i++)
|
||||
{
|
||||
IPdfElement result = ResolveIndirectReferences(array.Values[i], dictReferences);
|
||||
if(result != array.Values[i])
|
||||
{
|
||||
array.Values[i] = result;
|
||||
}
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
PdfDictionary dict = elem as PdfDictionary;
|
||||
if (dict != null)
|
||||
{
|
||||
List<string> keys = dict.Values.Keys.ToList();
|
||||
foreach (string key in keys)
|
||||
{
|
||||
IPdfElement value = dict.Values[key];
|
||||
IPdfElement result = ResolveIndirectReferences(value, dictReferences);
|
||||
if (result != value)
|
||||
{
|
||||
dict.Values[key] = result;
|
||||
}
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
private static void ExtractPages(PdfDictionary page, PdfDocument doc, PdfDictionary resources)
|
||||
{
|
||||
string type = page.GetParamAsString("Type");
|
||||
if (type == "Page")
|
||||
{
|
||||
PdfDocumentPage docPage = new PdfDocumentPage(page, resources);
|
||||
doc._pages.Add(docPage);
|
||||
return;
|
||||
}
|
||||
else if (type == "Pages")
|
||||
{
|
||||
if (page.Values.ContainsKey("Kids") == false || (page.Values["Kids"] is PdfArray) == false)
|
||||
{
|
||||
throw new Exception("PdfDocument: Pages \"Kids\" not found");
|
||||
}
|
||||
PdfArray kids = page.Values["Kids"] as PdfArray;
|
||||
foreach (IPdfElement elem in kids.Values)
|
||||
{
|
||||
PdfDictionary childPage = elem as PdfDictionary;
|
||||
if (page == null) { continue; }
|
||||
PdfDictionary resourcesAux = null;
|
||||
if (page.Values.ContainsKey("Resources"))
|
||||
{
|
||||
resourcesAux = page.Values["Resources"] as PdfDictionary;
|
||||
}
|
||||
ExtractPages(childPage, doc, resourcesAux);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(string.Format("PdfDocument: Unexpected page type, found: {0}", type));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
public static PdfDocument Load(string filename)
|
||||
{
|
||||
byte[] fileBytes = File.ReadAllBytes(filename);
|
||||
return Load(fileBytes);
|
||||
}
|
||||
|
||||
public static PdfDocument Load(byte[] data)
|
||||
{
|
||||
var doc = new PdfDocument();
|
||||
|
||||
// Parse data
|
||||
var parser = new PdfParser(data);
|
||||
do
|
||||
{
|
||||
PdfObject obj = parser.ParseObject(doc.Objects);
|
||||
if (obj != null)
|
||||
{
|
||||
if (obj.Data is PdfStream)
|
||||
{
|
||||
ApplyFiltersToStreams((PdfStream)obj.Data);
|
||||
}
|
||||
doc.Objects.Add(obj);
|
||||
}
|
||||
} while (parser.IsEndOfStream() == false);
|
||||
|
||||
// Expand Object Streams
|
||||
List<PdfObject> streamObjects = new List<PdfObject>();
|
||||
foreach (PdfObject obj in doc.Objects)
|
||||
{
|
||||
if (obj.Data.Type != PdfElementTypes.Stream) { continue; }
|
||||
PdfStream stream = obj.Data as PdfStream;
|
||||
|
||||
string type = stream.Dictionary.GetParamAsString("Type");
|
||||
long? number = stream.Dictionary.GetParamAsInt("N");
|
||||
long? first = stream.Dictionary.GetParamAsInt("First");
|
||||
if (type == "ObjStm" && number != null && first != null)
|
||||
{
|
||||
obj.UsageCount++;
|
||||
PdfParser parserAux = new PdfParser(stream.Data);
|
||||
streamObjects.AddRange(parserAux.ParseObjectStream((int)number, (long)first));
|
||||
}
|
||||
}
|
||||
foreach (PdfObject obj in streamObjects)
|
||||
{
|
||||
doc.Objects.Add(obj);
|
||||
}
|
||||
|
||||
// Build cross reference table
|
||||
Dictionary<int, PdfObject> dictObjects = new Dictionary<int, PdfObject>();
|
||||
foreach (PdfObject obj in doc.Objects)
|
||||
{
|
||||
if (dictObjects.ContainsKey(obj.ObjectID))
|
||||
{
|
||||
if (dictObjects[obj.ObjectID].ObjectGeneration < obj.ObjectGeneration)
|
||||
{
|
||||
dictObjects[obj.ObjectID] = obj;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dictObjects.Add(obj.ObjectID, obj);
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate full document to resolve all indirect references
|
||||
foreach(PdfObject obj in doc.Objects)
|
||||
{
|
||||
ResolveIndirectReferences(obj, dictObjects);
|
||||
}
|
||||
|
||||
// Search Catalog
|
||||
foreach(PdfObject obj in doc.Objects)
|
||||
{
|
||||
if ((obj.Data is PdfDictionary) == false) { continue; }
|
||||
string type = ((PdfDictionary)obj.Data).GetParamAsString("Type");
|
||||
if(type == "Catalog")
|
||||
{
|
||||
doc._catalog = (PdfDictionary)obj.Data;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if(doc._catalog == null)
|
||||
{
|
||||
throw new Exception("PdfDocument: Catalog not found");
|
||||
}
|
||||
|
||||
// Search pages
|
||||
if(doc.Catalog.Values.ContainsKey("Pages") == false ||
|
||||
(doc.Catalog.Values["Pages"] is PdfDictionary) == false)
|
||||
{
|
||||
throw new Exception("PdfDocument: Pages not found");
|
||||
}
|
||||
PdfDictionary pages = (PdfDictionary)doc.Catalog.Values["Pages"];
|
||||
PdfDictionary resources = null;
|
||||
if (doc.Catalog.Values.ContainsKey("Resources"))
|
||||
{
|
||||
resources = doc.Catalog.Values["Resources"] as PdfDictionary;
|
||||
}
|
||||
ExtractPages(pages, doc, resources);
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VAR.PdfTools
|
||||
{
|
||||
public class PdfDocumentPage
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private PdfDictionary _baseData = null;
|
||||
|
||||
private byte[] _content = null;
|
||||
|
||||
private PdfDictionary _resources = null;
|
||||
|
||||
private Dictionary<string, PdfFont> _fonts = new Dictionary<string, PdfFont>();
|
||||
|
||||
private List<PdfContentAction> _contentActions = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public PdfDictionary BaseData { get { return _baseData; } }
|
||||
|
||||
public byte[] Content { get { return _content; } }
|
||||
|
||||
public Dictionary<string, PdfFont> Fonts { get { return _fonts; } }
|
||||
|
||||
public List<PdfContentAction> ContentActions { get { return _contentActions; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Life cycle
|
||||
|
||||
public PdfDocumentPage(PdfDictionary baseData, PdfDictionary resources)
|
||||
{
|
||||
_baseData = baseData;
|
||||
string type = baseData.GetParamAsString("Type");
|
||||
if (type != "Page")
|
||||
{
|
||||
throw new Exception(string.Format("PdfDocumentPage: Expected dictionary of type:\"Page\". Found: {0}", type));
|
||||
}
|
||||
|
||||
// Get content, resources and fonts
|
||||
_content = _baseData.GetParamAsStream("Contents");
|
||||
if (_baseData.Values.ContainsKey("Resources") == false)
|
||||
{
|
||||
_resources = resources;
|
||||
}
|
||||
else
|
||||
{
|
||||
_resources = _baseData.Values["Resources"] as PdfDictionary;
|
||||
}
|
||||
if (_resources != null && _resources.Values.ContainsKey("Font"))
|
||||
{
|
||||
PdfDictionary fonts = _resources.Values["Font"] as PdfDictionary;
|
||||
foreach (KeyValuePair<string, IPdfElement> pair in fonts.Values)
|
||||
{
|
||||
var font = new PdfFont(pair.Value as PdfDictionary);
|
||||
_fonts.Add(pair.Key, font);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse content
|
||||
if (_content != null)
|
||||
{
|
||||
PdfParser parser = new PdfParser(_content);
|
||||
_contentActions = parser.ParseContent();
|
||||
}else
|
||||
{
|
||||
_contentActions = new List<PdfContentAction>();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace VAR.PdfTools
|
||||
{
|
||||
public enum PdfElementTypes
|
||||
{
|
||||
Undefined,
|
||||
Boolean,
|
||||
Integer,
|
||||
Real,
|
||||
String,
|
||||
Name,
|
||||
Array,
|
||||
Dictionary,
|
||||
Null,
|
||||
ObjectReference,
|
||||
Object,
|
||||
Stream,
|
||||
};
|
||||
|
||||
public interface IPdfElement
|
||||
{
|
||||
PdfElementTypes Type { get; }
|
||||
}
|
||||
|
||||
public class PdfBoolean : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.Boolean;
|
||||
public bool Value { get; set; }
|
||||
}
|
||||
|
||||
public class PdfInteger : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.Integer;
|
||||
public long Value { get; set; }
|
||||
}
|
||||
|
||||
public class PdfReal : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.Real;
|
||||
public double Value { get; set; }
|
||||
}
|
||||
|
||||
public class PdfString : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.String;
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class PdfName : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.Name;
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class PdfArray : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.Array;
|
||||
private List<IPdfElement> _values = new List<IPdfElement>();
|
||||
public List<IPdfElement> Values { get { return _values; } }
|
||||
}
|
||||
|
||||
public class PdfDictionary : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.Dictionary;
|
||||
private Dictionary<string, IPdfElement> _values = new Dictionary<string, IPdfElement>();
|
||||
public Dictionary<string, IPdfElement> Values { get { return _values; } }
|
||||
|
||||
public string GetParamAsString(string name)
|
||||
{
|
||||
if (Values.ContainsKey(name) == false) { return null; }
|
||||
|
||||
IPdfElement value = Values[name];
|
||||
if (value is PdfArray)
|
||||
{
|
||||
value = ((PdfArray)value).Values[0];
|
||||
}
|
||||
if (value is PdfName)
|
||||
{
|
||||
return ((PdfName)value).Value;
|
||||
}
|
||||
if (value is PdfString)
|
||||
{
|
||||
return ((PdfString)value).Value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public long? GetParamAsInt(string name)
|
||||
{
|
||||
if (Values.ContainsKey(name) == false) { return null; }
|
||||
|
||||
IPdfElement value = Values[name];
|
||||
if (value is PdfArray)
|
||||
{
|
||||
value = ((PdfArray)value).Values[0];
|
||||
}
|
||||
if (value is PdfInteger)
|
||||
{
|
||||
return ((PdfInteger)value).Value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] GetParamAsStream(string name)
|
||||
{
|
||||
if (Values.ContainsKey(name) == false) { return null; }
|
||||
|
||||
IPdfElement value = Values[name];
|
||||
if (value is PdfArray)
|
||||
{
|
||||
PdfArray array = value as PdfArray;
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
foreach(IPdfElement elem in array.Values)
|
||||
{
|
||||
PdfStream stream = elem as PdfStream;
|
||||
if (stream == null) { continue; }
|
||||
memStream.Write(stream.Data, 0, stream.Data.Length);
|
||||
}
|
||||
if (memStream.Length > 0)
|
||||
{
|
||||
return memStream.ToArray();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (value is PdfStream)
|
||||
{
|
||||
return ((PdfStream)value).Data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PdfNull : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.Null;
|
||||
}
|
||||
|
||||
public class PdfObjectReference : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.ObjectReference;
|
||||
public int ObjectID { get; set; }
|
||||
public int ObjectGeneration { get; set; }
|
||||
}
|
||||
|
||||
public class PdfStream : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.Stream;
|
||||
public PdfDictionary Dictionary { get; set; }
|
||||
public byte[] Data { get; set; }
|
||||
|
||||
public byte[] OriginalData { get; set; }
|
||||
public IPdfElement OriginalFilter { get; set; }
|
||||
}
|
||||
|
||||
public class PdfObject : IPdfElement
|
||||
{
|
||||
public PdfElementTypes Type { get; private set; } = PdfElementTypes.Object;
|
||||
public int ObjectID { get; set; }
|
||||
public int ObjectGeneration { get; set; }
|
||||
public IPdfElement Data { get; set; }
|
||||
public int UsageCount { get; set; } = 0;
|
||||
}
|
||||
|
||||
public static class PdfElementUtils
|
||||
{
|
||||
public static double GetReal(IPdfElement elem, double defaultValue)
|
||||
{
|
||||
if(elem == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (elem is PdfInteger)
|
||||
{
|
||||
return ((PdfInteger)elem).Value;
|
||||
}
|
||||
if (elem is PdfReal)
|
||||
{
|
||||
return ((PdfReal)elem).Value;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
public static long GetInt(IPdfElement elem, long defaultValue)
|
||||
{
|
||||
if (elem == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (elem is PdfInteger)
|
||||
{
|
||||
return ((PdfInteger)elem).Value;
|
||||
}
|
||||
if (elem is PdfReal)
|
||||
{
|
||||
return (long)((PdfReal)elem).Value;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VAR.PdfTools
|
||||
{
|
||||
public class PdfFont
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private PdfDictionary _baseData = null;
|
||||
|
||||
private Dictionary<char, string> _toUnicode = null;
|
||||
|
||||
private Dictionary<char, double> _widths = null;
|
||||
|
||||
private double _height = 1.0;
|
||||
|
||||
private bool _tainted = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public PdfDictionary BaseData { get { return _baseData; } }
|
||||
|
||||
public double Height { get { return _height; } }
|
||||
|
||||
public bool Tainted { get { return _tainted; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Life cycle
|
||||
|
||||
public PdfFont(PdfDictionary baseData)
|
||||
{
|
||||
_baseData = baseData;
|
||||
string type = baseData.GetParamAsString("Type");
|
||||
if (type != "Font")
|
||||
{
|
||||
// NOTE: Type="Font" is Required by the standard, continuing anyway
|
||||
_tainted = true;
|
||||
}
|
||||
|
||||
if (baseData.Values.ContainsKey("ToUnicode"))
|
||||
{
|
||||
byte[] toUnicodeStream = ((PdfStream)baseData.Values["ToUnicode"]).Data;
|
||||
PdfParser parser = new PdfParser(toUnicodeStream);
|
||||
_toUnicode = parser.ParseToUnicode();
|
||||
}
|
||||
|
||||
if (_baseData.Values.ContainsKey("FirstChar") && _baseData.Values.ContainsKey("LastChar") && _baseData.Values.ContainsKey("Widths"))
|
||||
{
|
||||
double glyphSpaceToTextSpace = 1000.0; // FIXME: SubType:Type3 Uses a FontMatrix that may not correspond to 1/1000th
|
||||
_widths = new Dictionary<char, double>();
|
||||
char firstChar = (char)_baseData.GetParamAsInt("FirstChar");
|
||||
char lastChar = (char)_baseData.GetParamAsInt("LastChar");
|
||||
PdfArray widths = _baseData.Values["Widths"] as PdfArray;
|
||||
char actualChar = firstChar;
|
||||
foreach (IPdfElement elem in widths.Values)
|
||||
{
|
||||
PdfReal widthReal = elem as PdfReal;
|
||||
if (widthReal != null)
|
||||
{
|
||||
_widths.Add(actualChar, widthReal.Value / glyphSpaceToTextSpace);
|
||||
actualChar++;
|
||||
continue;
|
||||
}
|
||||
PdfInteger widthInt = elem as PdfInteger;
|
||||
if (widthInt != null)
|
||||
{
|
||||
_widths.Add(actualChar, widthInt.Value / glyphSpaceToTextSpace);
|
||||
actualChar++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// FIMXE: Calculate real height
|
||||
}
|
||||
else
|
||||
{
|
||||
string baseFont = _baseData.GetParamAsString("BaseFont");
|
||||
if (baseFont == "Times-Roman")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Times_Roman.Widths;
|
||||
_height = PdfStandar14FontMetrics.Times_Roman.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Times-Bold")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Times_Bold.Widths;
|
||||
_height = PdfStandar14FontMetrics.Times_Bold.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Times-Italic")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Times_Italic.Widths;
|
||||
_height = PdfStandar14FontMetrics.Times_Italic.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Times-BoldItalic")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Times_BoldItalic.Widths;
|
||||
_height = PdfStandar14FontMetrics.Times_BoldItalic.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Helvetica")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Helvetica.Widths;
|
||||
_height = PdfStandar14FontMetrics.Helvetica.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Helvetica-Bold")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Helvetica_Bold.Widths;
|
||||
_height = PdfStandar14FontMetrics.Helvetica_Bold.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Helvetica-Oblique")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Helvetica_Oblique.Widths;
|
||||
_height = PdfStandar14FontMetrics.Helvetica_Oblique.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Helvetica-BoldOblique")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Helvetica_BoldOblique.Widths;
|
||||
_height = PdfStandar14FontMetrics.Helvetica_BoldOblique.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Courier")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Courier.Widths;
|
||||
_height = PdfStandar14FontMetrics.Courier.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Courier-Bold")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Courier_Bold.Widths;
|
||||
_height = PdfStandar14FontMetrics.Courier_Bold.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Courier-Oblique")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Courier_Oblique.Widths;
|
||||
_height = PdfStandar14FontMetrics.Courier_Oblique.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Courier-BoldOblique")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Courier_BoldOblique.Widths;
|
||||
_height = PdfStandar14FontMetrics.Courier_BoldOblique.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "Symbol")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.Symbol.Widths;
|
||||
_height = PdfStandar14FontMetrics.Symbol.ApproxHeight;
|
||||
}
|
||||
if (baseFont == "ZapfDingbats")
|
||||
{
|
||||
_widths = PdfStandar14FontMetrics.ZapfDingbats.Widths;
|
||||
_height = PdfStandar14FontMetrics.ZapfDingbats.ApproxHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
public string ToUnicode(char character)
|
||||
{
|
||||
if (_toUnicode == null)
|
||||
{
|
||||
// FIXME: use standar tables
|
||||
return new string(character, 1);
|
||||
}
|
||||
|
||||
if (_toUnicode.ContainsKey(character))
|
||||
{
|
||||
return _toUnicode[character];
|
||||
}
|
||||
|
||||
return new string(character, 1);
|
||||
}
|
||||
|
||||
public double GetCharWidth(char character)
|
||||
{
|
||||
if (_widths == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (_widths.ContainsKey(character))
|
||||
{
|
||||
return _widths[character];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,582 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace VAR.PdfTools
|
||||
{
|
||||
public class Vector3D
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
public double[] _vector = new double[3];
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public double[] Vector { get { return _vector; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Creator
|
||||
|
||||
public Vector3D()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
_vector[0] = 0.0;
|
||||
_vector[1] = 0.0;
|
||||
_vector[2] = 1.0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class Matrix3x3
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
public double[,] _matrix = new double[3, 3];
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public double[,] Matrix { get { return _matrix; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Creator
|
||||
|
||||
public Matrix3x3()
|
||||
{
|
||||
Idenity();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
public void Idenity()
|
||||
{
|
||||
_matrix[0, 0] = 1.0;
|
||||
_matrix[0, 1] = 0.0;
|
||||
_matrix[0, 2] = 0.0;
|
||||
_matrix[1, 0] = 0.0;
|
||||
_matrix[1, 1] = 1.0;
|
||||
_matrix[1, 2] = 0.0;
|
||||
_matrix[2, 0] = 0.0;
|
||||
_matrix[2, 1] = 0.0;
|
||||
_matrix[2, 2] = 1.0;
|
||||
}
|
||||
|
||||
public Vector3D Multiply(Vector3D vect)
|
||||
{
|
||||
Vector3D vectResult = new Vector3D();
|
||||
|
||||
vectResult.Vector[0] = (vect.Vector[0] * _matrix[0, 0]) + (vect.Vector[1] * _matrix[0, 1]) + (vect.Vector[2] * _matrix[0, 2]);
|
||||
vectResult.Vector[1] = (vect.Vector[0] * _matrix[1, 0]) + (vect.Vector[1] * _matrix[1, 1]) + (vect.Vector[2] * _matrix[1, 2]);
|
||||
vectResult.Vector[2] = (vect.Vector[0] * _matrix[2, 0]) + (vect.Vector[1] * _matrix[2, 1]) + (vect.Vector[2] * _matrix[2, 2]);
|
||||
|
||||
return vectResult;
|
||||
}
|
||||
|
||||
public Matrix3x3 Multiply(Matrix3x3 matrix)
|
||||
{
|
||||
Matrix3x3 newMatrix = new Matrix3x3();
|
||||
|
||||
newMatrix._matrix[0, 0] = (_matrix[0, 0] * matrix._matrix[0, 0]) + (_matrix[1, 0] * matrix._matrix[0, 1]) + (_matrix[2, 0] * matrix._matrix[0, 2]);
|
||||
newMatrix._matrix[0, 1] = (_matrix[0, 1] * matrix._matrix[0, 0]) + (_matrix[1, 1] * matrix._matrix[0, 1]) + (_matrix[2, 1] * matrix._matrix[0, 2]);
|
||||
newMatrix._matrix[0, 2] = (_matrix[0, 2] * matrix._matrix[0, 0]) + (_matrix[1, 2] * matrix._matrix[0, 1]) + (_matrix[2, 2] * matrix._matrix[0, 2]);
|
||||
newMatrix._matrix[1, 0] = (_matrix[0, 0] * matrix._matrix[1, 0]) + (_matrix[1, 0] * matrix._matrix[1, 1]) + (_matrix[2, 0] * matrix._matrix[1, 2]);
|
||||
newMatrix._matrix[1, 1] = (_matrix[0, 1] * matrix._matrix[1, 0]) + (_matrix[1, 1] * matrix._matrix[1, 1]) + (_matrix[2, 1] * matrix._matrix[1, 2]);
|
||||
newMatrix._matrix[1, 2] = (_matrix[0, 2] * matrix._matrix[1, 0]) + (_matrix[1, 2] * matrix._matrix[1, 1]) + (_matrix[2, 2] * matrix._matrix[1, 2]);
|
||||
newMatrix._matrix[2, 0] = (_matrix[0, 0] * matrix._matrix[2, 0]) + (_matrix[1, 0] * matrix._matrix[2, 1]) + (_matrix[2, 0] * matrix._matrix[2, 2]);
|
||||
newMatrix._matrix[2, 1] = (_matrix[0, 1] * matrix._matrix[2, 0]) + (_matrix[1, 1] * matrix._matrix[2, 1]) + (_matrix[2, 1] * matrix._matrix[2, 2]);
|
||||
newMatrix._matrix[2, 2] = (_matrix[0, 2] * matrix._matrix[2, 0]) + (_matrix[1, 2] * matrix._matrix[2, 1]) + (_matrix[2, 2] * matrix._matrix[2, 2]);
|
||||
|
||||
return newMatrix;
|
||||
}
|
||||
|
||||
public Matrix3x3 Copy()
|
||||
{
|
||||
Matrix3x3 newMatrix = new Matrix3x3();
|
||||
|
||||
newMatrix._matrix[0, 0] = _matrix[0, 0];
|
||||
newMatrix._matrix[0, 1] = _matrix[0, 1];
|
||||
newMatrix._matrix[0, 2] = _matrix[0, 2];
|
||||
newMatrix._matrix[1, 0] = _matrix[1, 0];
|
||||
newMatrix._matrix[1, 1] = _matrix[1, 1];
|
||||
newMatrix._matrix[1, 2] = _matrix[1, 2];
|
||||
newMatrix._matrix[2, 0] = _matrix[2, 0];
|
||||
newMatrix._matrix[2, 1] = _matrix[2, 1];
|
||||
newMatrix._matrix[2, 2] = _matrix[2, 2];
|
||||
|
||||
return newMatrix;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class PdfTextElement
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public PdfFont Font { get; set; }
|
||||
|
||||
public double FontSize { get; set; }
|
||||
|
||||
public Matrix3x3 Matrix { get; set; }
|
||||
|
||||
public string RawText { get; set; }
|
||||
|
||||
public string VisibleText { get; set; }
|
||||
|
||||
public double VisibleWidth { get; set; }
|
||||
|
||||
public double VisibleHeight { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
public double GetX()
|
||||
{
|
||||
return Matrix.Matrix[0, 2];
|
||||
}
|
||||
|
||||
public double GetY()
|
||||
{
|
||||
return Matrix.Matrix[1, 2];
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class PdfTextExtractor
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private PdfDocumentPage _page = null;
|
||||
|
||||
private List<PdfTextElement> _textElements = new List<PdfTextElement>();
|
||||
|
||||
// Graphics state
|
||||
private List<Matrix3x3> _graphicsMatrixStack = new List<Matrix3x3>();
|
||||
private Matrix3x3 _graphicsMatrix = new Matrix3x3();
|
||||
|
||||
// Text state
|
||||
private PdfFont _font = null;
|
||||
private double _fontSize = 1;
|
||||
private double _textLeading = 0;
|
||||
|
||||
// Text object state
|
||||
private bool inText = false;
|
||||
private Matrix3x3 _textMatrix = new Matrix3x3();
|
||||
private StringBuilder _sbText = new StringBuilder();
|
||||
private double _textWidth = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public PdfDocumentPage Page { get { return _page; } }
|
||||
|
||||
public List<PdfTextElement> Elements { get { return _textElements; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region lifecycle
|
||||
|
||||
public PdfTextExtractor(PdfDocumentPage page)
|
||||
{
|
||||
_page = page;
|
||||
ProcessPage();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Utility methods
|
||||
|
||||
private string PdfString_ToUnicode(string text, PdfFont font)
|
||||
{
|
||||
if (font == null)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
StringBuilder sbText = new StringBuilder();
|
||||
foreach (char c in text)
|
||||
{
|
||||
sbText.Append(font.ToUnicode(c).Replace("\0", ""));
|
||||
}
|
||||
return sbText.ToString();
|
||||
}
|
||||
|
||||
private void FlushTextElement()
|
||||
{
|
||||
if (_sbText.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PdfTextElement textElem = new PdfTextElement();
|
||||
textElem.Font = _font;
|
||||
textElem.FontSize = _fontSize;
|
||||
textElem.Matrix = _textMatrix.Multiply(_graphicsMatrix);
|
||||
textElem.RawText = _sbText.ToString();
|
||||
textElem.VisibleText = PdfString_ToUnicode(textElem.RawText, _font);
|
||||
textElem.VisibleWidth = _textWidth * textElem.Matrix.Matrix[0, 0];
|
||||
textElem.VisibleHeight = (_font.Height * _fontSize) * textElem.Matrix.Matrix[1, 1];
|
||||
_textElements.Add(textElem);
|
||||
|
||||
_sbText = new StringBuilder();
|
||||
_textWidth = 0;
|
||||
}
|
||||
|
||||
private PdfTextElement FindElementByText(string text)
|
||||
{
|
||||
foreach (PdfTextElement elem in _textElements)
|
||||
{
|
||||
if (elem.VisibleText == text)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool TextElementVerticalIntersection(PdfTextElement elem1, PdfTextElement elem2)
|
||||
{
|
||||
double elem1X1 = elem1.GetX();
|
||||
double elem1X2 = elem1.GetX() + elem1.VisibleWidth;
|
||||
double elem2X1 = elem2.GetX();
|
||||
double elem2X2 = elem2.GetX() + elem2.VisibleWidth;
|
||||
|
||||
return elem1X2 >= elem2X1 && elem2X2 >= elem1X1;
|
||||
}
|
||||
|
||||
private bool TextElementHorizontalIntersection(PdfTextElement elem1, PdfTextElement elem2)
|
||||
{
|
||||
double elem1Y1 = elem1.GetY();
|
||||
double elem1Y2 = elem1.GetY() + elem1.VisibleHeight;
|
||||
double elem2Y1 = elem2.GetY();
|
||||
double elem2Y2 = elem2.GetY() + elem2.VisibleHeight;
|
||||
|
||||
return elem1Y2 >= elem2Y1 && elem2Y2 >= elem1Y1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operations
|
||||
|
||||
private void OpPushGraphState()
|
||||
{
|
||||
_graphicsMatrixStack.Add(_graphicsMatrix.Copy());
|
||||
}
|
||||
|
||||
private void OpPopGraphState()
|
||||
{
|
||||
_graphicsMatrix = _graphicsMatrixStack[_graphicsMatrixStack.Count - 1];
|
||||
_graphicsMatrixStack.RemoveAt(_graphicsMatrixStack.Count - 1);
|
||||
}
|
||||
|
||||
private void OpSetGraphMatrix(double a, double b, double c, double d, double e, double f)
|
||||
{
|
||||
_graphicsMatrix.Matrix[0, 0] = a;
|
||||
_graphicsMatrix.Matrix[1, 0] = b;
|
||||
_graphicsMatrix.Matrix[2, 0] = 0;
|
||||
_graphicsMatrix.Matrix[0, 1] = c;
|
||||
_graphicsMatrix.Matrix[1, 1] = d;
|
||||
_graphicsMatrix.Matrix[2, 1] = 0;
|
||||
_graphicsMatrix.Matrix[0, 2] = e;
|
||||
_graphicsMatrix.Matrix[1, 2] = f;
|
||||
_graphicsMatrix.Matrix[2, 2] = 1;
|
||||
}
|
||||
|
||||
private void OpBeginText()
|
||||
{
|
||||
_textMatrix.Idenity();
|
||||
inText = true;
|
||||
}
|
||||
|
||||
private void OpEndText()
|
||||
{
|
||||
FlushTextElement();
|
||||
inText = false;
|
||||
}
|
||||
|
||||
private void OpTextFont(string fontName, double size)
|
||||
{
|
||||
FlushTextElement();
|
||||
_font = _page.Fonts[fontName];
|
||||
_fontSize = size;
|
||||
}
|
||||
|
||||
private void OpTextLeading(double textLeading)
|
||||
{
|
||||
_textLeading = textLeading;
|
||||
}
|
||||
|
||||
private void OpTesDisplace(double x, double y)
|
||||
{
|
||||
FlushTextElement();
|
||||
var newMatrix = new Matrix3x3();
|
||||
newMatrix.Matrix[0, 2] = x;
|
||||
newMatrix.Matrix[1, 2] = y;
|
||||
_textMatrix = newMatrix.Multiply(_textMatrix);
|
||||
}
|
||||
|
||||
private void OpTextLineFeed()
|
||||
{
|
||||
OpTesDisplace(0, -_textLeading);
|
||||
}
|
||||
|
||||
private void OpSetTextMatrix(double a, double b, double c, double d, double e, double f)
|
||||
{
|
||||
FlushTextElement();
|
||||
_textMatrix.Matrix[0, 0] = a;
|
||||
_textMatrix.Matrix[1, 0] = b;
|
||||
_textMatrix.Matrix[2, 0] = 0;
|
||||
_textMatrix.Matrix[0, 1] = c;
|
||||
_textMatrix.Matrix[1, 1] = d;
|
||||
_textMatrix.Matrix[2, 1] = 0;
|
||||
_textMatrix.Matrix[0, 2] = e;
|
||||
_textMatrix.Matrix[1, 2] = f;
|
||||
_textMatrix.Matrix[2, 2] = 1;
|
||||
}
|
||||
|
||||
private void OpTextPut(string text)
|
||||
{
|
||||
if (inText == false) { return; }
|
||||
_sbText.Append(text);
|
||||
if (_font != null)
|
||||
{
|
||||
foreach (char c in text)
|
||||
{
|
||||
_textWidth += _font.GetCharWidth(c) * _fontSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OpTextPutMultiple(PdfArray array)
|
||||
{
|
||||
if (inText == false) { return; }
|
||||
foreach (IPdfElement elem in array.Values)
|
||||
{
|
||||
if(elem is PdfString)
|
||||
{
|
||||
OpTextPut(((PdfString)elem).Value);
|
||||
}
|
||||
else if(elem is PdfInteger || elem is PdfReal)
|
||||
{
|
||||
double spacing = PdfElementUtils.GetReal(elem, 0);
|
||||
_textWidth += spacing;
|
||||
}
|
||||
else if(elem is PdfArray)
|
||||
{
|
||||
OpTextPutMultiple(((PdfArray)elem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
|
||||
private void ProcessPage()
|
||||
{
|
||||
foreach (PdfContentAction action in _page.ContentActions)
|
||||
{
|
||||
// Graphics Operations
|
||||
if (action.Token == "q")
|
||||
{
|
||||
OpPushGraphState();
|
||||
}
|
||||
else if (action.Token == "Q")
|
||||
{
|
||||
OpPopGraphState();
|
||||
}
|
||||
else if (action.Token == "cm")
|
||||
{
|
||||
double a = PdfElementUtils.GetReal(action.Parameters[0], 0);
|
||||
double b = PdfElementUtils.GetReal(action.Parameters[1], 0);
|
||||
double c = PdfElementUtils.GetReal(action.Parameters[2], 0);
|
||||
double d = PdfElementUtils.GetReal(action.Parameters[3], 0);
|
||||
double e = PdfElementUtils.GetReal(action.Parameters[4], 0);
|
||||
double f = PdfElementUtils.GetReal(action.Parameters[5], 0);
|
||||
OpSetGraphMatrix(a, b, c, d, e, f);
|
||||
}
|
||||
|
||||
// Text Operations
|
||||
else if (action.Token == "BT")
|
||||
{
|
||||
OpBeginText();
|
||||
}
|
||||
else if (action.Token == "ET")
|
||||
{
|
||||
OpEndText();
|
||||
}
|
||||
else if (action.Token == "Tc")
|
||||
{
|
||||
// FIXME: Char spacing
|
||||
}
|
||||
else if (action.Token == "Tw")
|
||||
{
|
||||
// FIXME: Word spacing
|
||||
}
|
||||
else if (action.Token == "Tz")
|
||||
{
|
||||
// FIXME: Horizontal Scale
|
||||
}
|
||||
else if (action.Token == "Tf")
|
||||
{
|
||||
string fontName = ((PdfName)action.Parameters[0]).Value;
|
||||
double fontSize = PdfElementUtils.GetReal(action.Parameters[1], 0);
|
||||
OpTextFont(fontName, fontSize);
|
||||
}
|
||||
else if (action.Token == "TL")
|
||||
{
|
||||
double leading = PdfElementUtils.GetReal(action.Parameters[0], 0);
|
||||
OpTextLeading(leading);
|
||||
}
|
||||
else if (action.Token == "Tr")
|
||||
{
|
||||
// FIXME: Rendering mode
|
||||
}
|
||||
else if (action.Token == "Ts")
|
||||
{
|
||||
// FIXME: Text rise
|
||||
}
|
||||
else if (action.Token == "Td")
|
||||
{
|
||||
double x = PdfElementUtils.GetReal(action.Parameters[0], 0);
|
||||
double y = PdfElementUtils.GetReal(action.Parameters[1], 0);
|
||||
OpTesDisplace(x, y);
|
||||
}
|
||||
else if (action.Token == "TD")
|
||||
{
|
||||
double x = PdfElementUtils.GetReal(action.Parameters[0], 0);
|
||||
double y = PdfElementUtils.GetReal(action.Parameters[1], 0);
|
||||
OpTextLeading(-y);
|
||||
OpTesDisplace(x, y);
|
||||
}
|
||||
else if (action.Token == "Tm")
|
||||
{
|
||||
double a = PdfElementUtils.GetReal(action.Parameters[0], 0);
|
||||
double b = PdfElementUtils.GetReal(action.Parameters[1], 0);
|
||||
double c = PdfElementUtils.GetReal(action.Parameters[2], 0);
|
||||
double d = PdfElementUtils.GetReal(action.Parameters[3], 0);
|
||||
double e = PdfElementUtils.GetReal(action.Parameters[4], 0);
|
||||
double f = PdfElementUtils.GetReal(action.Parameters[5], 0);
|
||||
OpSetTextMatrix(a, b, c, d, e, f);
|
||||
}
|
||||
else if (action.Token == "T*")
|
||||
{
|
||||
OpTextLineFeed();
|
||||
}
|
||||
else if (action.Token == "Tj")
|
||||
{
|
||||
OpTextPut(((PdfString)action.Parameters[0]).Value);
|
||||
}
|
||||
else if (action.Token == "'")
|
||||
{
|
||||
OpTextLineFeed();
|
||||
OpTextPut(((PdfString)action.Parameters[0]).Value);
|
||||
}
|
||||
else if (action.Token == "\"")
|
||||
{
|
||||
double wordSpacing = PdfElementUtils.GetReal(action.Parameters[0], 0);
|
||||
double charSpacing = PdfElementUtils.GetReal(action.Parameters[1], 0);
|
||||
OpTextPut(((PdfString)action.Parameters[2]).Value);
|
||||
}
|
||||
else if (action.Token == "TJ")
|
||||
{
|
||||
OpTextPutMultiple(((PdfArray)action.Parameters[0]));
|
||||
}
|
||||
}
|
||||
FlushTextElement();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
public List<string> GetColumn(string column)
|
||||
{
|
||||
PdfTextElement columnHead = FindElementByText(column);
|
||||
if(columnHead == null)
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
double headY = columnHead.GetY();
|
||||
|
||||
// Get all the elements that intersects vertically and sort
|
||||
var columnData = new List<PdfTextElement>();
|
||||
foreach (PdfTextElement elem in _textElements)
|
||||
{
|
||||
if (TextElementVerticalIntersection(columnHead, elem) == false) { continue; }
|
||||
double elemY = elem.GetY();
|
||||
if (elemY >= headY) { continue; }
|
||||
|
||||
columnData.Add(elem);
|
||||
}
|
||||
columnData = columnData.OrderByDescending(elem => elem.GetY()).ToList();
|
||||
|
||||
// Filter only nearest elements
|
||||
var result = new List<string>();
|
||||
double prevY = headY;
|
||||
double medDiff = 0;
|
||||
bool first = true;
|
||||
foreach (PdfTextElement elem in columnData)
|
||||
{
|
||||
double elemY = elem.GetY();
|
||||
double diff = prevY - elemY;
|
||||
prevY = elemY;
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
medDiff = diff;
|
||||
}
|
||||
if (diff > medDiff) { break; }
|
||||
medDiff = (medDiff + diff) / 2;
|
||||
|
||||
result.Add(elem.VisibleText);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public string GetField(string column)
|
||||
{
|
||||
PdfTextElement fieldTitle = FindElementByText(column);
|
||||
if (fieldTitle == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
double titleX = fieldTitle.GetX();
|
||||
var fieldData = new List<PdfTextElement>();
|
||||
|
||||
|
||||
foreach (PdfTextElement elem in _textElements)
|
||||
{
|
||||
if (TextElementHorizontalIntersection(fieldTitle, elem) == false) { continue; }
|
||||
double elemX = elem.GetX();
|
||||
if (elemX <= titleX) { continue; }
|
||||
|
||||
fieldData.Add(elem);
|
||||
}
|
||||
|
||||
if(fieldData.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return fieldData.OrderBy(elem => elem.GetX()).FirstOrDefault().VisibleText;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("VAR.PdfTools")]
|
||||
[assembly: AssemblyDescription("PdfTools Library")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("VAR")]
|
||||
[assembly: AssemblyProduct("VAR.PdfTools")]
|
||||
[assembly: AssemblyCopyright("Copyright © VAR 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("eb7e003a-6a95-4002-809f-926c7c8a11e9")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{EB7E003A-6A95-4002-809F-926C7C8A11E9}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>VAR.PdfTools</RootNamespace>
|
||||
<AssemblyName>VAR.PdfTools</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="PdfContentAction.cs" />
|
||||
<Compile Include="PdfDocument.cs" />
|
||||
<Compile Include="PdfDocumentPage.cs" />
|
||||
<Compile Include="PdfElements.cs" />
|
||||
<Compile Include="PdfFont.cs" />
|
||||
<Compile Include="PdfParser.cs" />
|
||||
<Compile Include="PdfStandar14FontMetrics.cs" />
|
||||
<Compile Include="PdfTextExtractor.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</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>
|
||||
0
issues/.keep
Normal file
0
issues/.keep
Normal file
6
issues/1.yaml
Normal file
6
issues/1.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
id: 1
|
||||
title: Fusionar PDFs
|
||||
state: open
|
||||
tags: enhancement
|
||||
|
||||
|
||||
6
issues/2.yaml
Normal file
6
issues/2.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
id: 2
|
||||
title: Mejoras
|
||||
state: open
|
||||
tags: enhancement
|
||||
|
||||
https://filingdb.com/b/pdf-text-extraction
|
||||
Reference in New Issue
Block a user