Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 06de734658 | |||
| 901d7e62ca | |||
| 631f8c34b2 | |||
| 7ac6b19331 | |||
| 34e7424273 | |||
| 6b8bbc367f | |||
| 6dfc248b9a | |||
| f3aca2ffa5 |
200
VAR.PdfTools.Workbench/FrmPdfInfo.Designer.cs
generated
200
VAR.PdfTools.Workbench/FrmPdfInfo.Designer.cs
generated
@@ -34,13 +34,19 @@
|
|||||||
this.txtPdfPath = new System.Windows.Forms.TextBox();
|
this.txtPdfPath = new System.Windows.Forms.TextBox();
|
||||||
this.txtOutput = new System.Windows.Forms.TextBox();
|
this.txtOutput = new System.Windows.Forms.TextBox();
|
||||||
this.btnProcess = new System.Windows.Forms.Button();
|
this.btnProcess = new System.Windows.Forms.Button();
|
||||||
this.btnGetColumn = new System.Windows.Forms.Button();
|
this.btnGetColumn1 = new System.Windows.Forms.Button();
|
||||||
this.txtColumnName = new System.Windows.Forms.TextBox();
|
this.txtField1 = new System.Windows.Forms.TextBox();
|
||||||
this.txtFieldName = new System.Windows.Forms.TextBox();
|
this.btnGetField1 = new System.Windows.Forms.Button();
|
||||||
this.btnGetField = new System.Windows.Forms.Button();
|
this.btnHasText1 = new System.Windows.Forms.Button();
|
||||||
this.txtText = new System.Windows.Forms.TextBox();
|
|
||||||
this.btnHasText = new System.Windows.Forms.Button();
|
|
||||||
this.btnRender = new System.Windows.Forms.Button();
|
this.btnRender = new System.Windows.Forms.Button();
|
||||||
|
this.btnHasText2 = new System.Windows.Forms.Button();
|
||||||
|
this.btnGetField2 = new System.Windows.Forms.Button();
|
||||||
|
this.txtField2 = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnGetColumn2 = new System.Windows.Forms.Button();
|
||||||
|
this.btnHasText3 = new System.Windows.Forms.Button();
|
||||||
|
this.btnGetField3 = new System.Windows.Forms.Button();
|
||||||
|
this.txtField3 = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnGetColumn3 = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// lblOutputs
|
// lblOutputs
|
||||||
@@ -109,56 +115,42 @@
|
|||||||
this.btnProcess.UseVisualStyleBackColor = true;
|
this.btnProcess.UseVisualStyleBackColor = true;
|
||||||
this.btnProcess.Click += new System.EventHandler(this.btnProcess_Click);
|
this.btnProcess.Click += new System.EventHandler(this.btnProcess_Click);
|
||||||
//
|
//
|
||||||
// btnGetColumn
|
// btnGetColumn1
|
||||||
//
|
//
|
||||||
this.btnGetColumn.Location = new System.Drawing.Point(163, 51);
|
this.btnGetColumn1.Location = new System.Drawing.Point(292, 51);
|
||||||
this.btnGetColumn.Name = "btnGetColumn";
|
this.btnGetColumn1.Name = "btnGetColumn1";
|
||||||
this.btnGetColumn.Size = new System.Drawing.Size(75, 23);
|
this.btnGetColumn1.Size = new System.Drawing.Size(60, 23);
|
||||||
this.btnGetColumn.TabIndex = 12;
|
this.btnGetColumn1.TabIndex = 12;
|
||||||
this.btnGetColumn.Text = "GetColumn";
|
this.btnGetColumn1.Text = "GetColumn";
|
||||||
this.btnGetColumn.UseVisualStyleBackColor = true;
|
this.btnGetColumn1.UseVisualStyleBackColor = true;
|
||||||
this.btnGetColumn.Click += new System.EventHandler(this.btnGetColumn_Click);
|
this.btnGetColumn1.Click += new System.EventHandler(this.btnGetColumn1_Click);
|
||||||
//
|
//
|
||||||
// txtColumnName
|
// txtField1
|
||||||
//
|
//
|
||||||
this.txtColumnName.Location = new System.Drawing.Point(15, 53);
|
this.txtField1.Location = new System.Drawing.Point(15, 53);
|
||||||
this.txtColumnName.Name = "txtColumnName";
|
this.txtField1.Name = "txtField1";
|
||||||
this.txtColumnName.Size = new System.Drawing.Size(142, 20);
|
this.txtField1.Size = new System.Drawing.Size(142, 20);
|
||||||
this.txtColumnName.TabIndex = 13;
|
this.txtField1.TabIndex = 13;
|
||||||
//
|
//
|
||||||
// txtFieldName
|
// btnGetField1
|
||||||
//
|
//
|
||||||
this.txtFieldName.Location = new System.Drawing.Point(15, 82);
|
this.btnGetField1.Location = new System.Drawing.Point(226, 51);
|
||||||
this.txtFieldName.Name = "txtFieldName";
|
this.btnGetField1.Name = "btnGetField1";
|
||||||
this.txtFieldName.Size = new System.Drawing.Size(142, 20);
|
this.btnGetField1.Size = new System.Drawing.Size(60, 23);
|
||||||
this.txtFieldName.TabIndex = 15;
|
this.btnGetField1.TabIndex = 14;
|
||||||
|
this.btnGetField1.Text = "GetField";
|
||||||
|
this.btnGetField1.UseVisualStyleBackColor = true;
|
||||||
|
this.btnGetField1.Click += new System.EventHandler(this.btnGetField1_Click);
|
||||||
//
|
//
|
||||||
// btnGetField
|
// btnHasText1
|
||||||
//
|
//
|
||||||
this.btnGetField.Location = new System.Drawing.Point(163, 80);
|
this.btnHasText1.Location = new System.Drawing.Point(163, 51);
|
||||||
this.btnGetField.Name = "btnGetField";
|
this.btnHasText1.Name = "btnHasText1";
|
||||||
this.btnGetField.Size = new System.Drawing.Size(75, 23);
|
this.btnHasText1.Size = new System.Drawing.Size(57, 23);
|
||||||
this.btnGetField.TabIndex = 14;
|
this.btnHasText1.TabIndex = 16;
|
||||||
this.btnGetField.Text = "GetField";
|
this.btnHasText1.Text = "HasText";
|
||||||
this.btnGetField.UseVisualStyleBackColor = true;
|
this.btnHasText1.UseVisualStyleBackColor = true;
|
||||||
this.btnGetField.Click += new System.EventHandler(this.btnGetField_Click);
|
this.btnHasText1.Click += new System.EventHandler(this.btnHasText1_Click);
|
||||||
//
|
|
||||||
// txtText
|
|
||||||
//
|
|
||||||
this.txtText.Location = new System.Drawing.Point(15, 111);
|
|
||||||
this.txtText.Name = "txtText";
|
|
||||||
this.txtText.Size = new System.Drawing.Size(142, 20);
|
|
||||||
this.txtText.TabIndex = 17;
|
|
||||||
//
|
|
||||||
// btnHasText
|
|
||||||
//
|
|
||||||
this.btnHasText.Location = new System.Drawing.Point(163, 109);
|
|
||||||
this.btnHasText.Name = "btnHasText";
|
|
||||||
this.btnHasText.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.btnHasText.TabIndex = 16;
|
|
||||||
this.btnHasText.Text = "HasText";
|
|
||||||
this.btnHasText.UseVisualStyleBackColor = true;
|
|
||||||
this.btnHasText.Click += new System.EventHandler(this.btnHasText_Click);
|
|
||||||
//
|
//
|
||||||
// btnRender
|
// btnRender
|
||||||
//
|
//
|
||||||
@@ -171,18 +163,98 @@
|
|||||||
this.btnRender.UseVisualStyleBackColor = true;
|
this.btnRender.UseVisualStyleBackColor = true;
|
||||||
this.btnRender.Click += new System.EventHandler(this.btnRender_Click);
|
this.btnRender.Click += new System.EventHandler(this.btnRender_Click);
|
||||||
//
|
//
|
||||||
|
// btnHasText2
|
||||||
|
//
|
||||||
|
this.btnHasText2.Location = new System.Drawing.Point(163, 80);
|
||||||
|
this.btnHasText2.Name = "btnHasText2";
|
||||||
|
this.btnHasText2.Size = new System.Drawing.Size(57, 23);
|
||||||
|
this.btnHasText2.TabIndex = 22;
|
||||||
|
this.btnHasText2.Text = "HasText";
|
||||||
|
this.btnHasText2.UseVisualStyleBackColor = true;
|
||||||
|
this.btnHasText2.Click += new System.EventHandler(this.btnHasText2_Click);
|
||||||
|
//
|
||||||
|
// btnGetField2
|
||||||
|
//
|
||||||
|
this.btnGetField2.Location = new System.Drawing.Point(226, 80);
|
||||||
|
this.btnGetField2.Name = "btnGetField2";
|
||||||
|
this.btnGetField2.Size = new System.Drawing.Size(60, 23);
|
||||||
|
this.btnGetField2.TabIndex = 21;
|
||||||
|
this.btnGetField2.Text = "GetField";
|
||||||
|
this.btnGetField2.UseVisualStyleBackColor = true;
|
||||||
|
this.btnGetField2.Click += new System.EventHandler(this.btnGetField2_Click);
|
||||||
|
//
|
||||||
|
// txtField2
|
||||||
|
//
|
||||||
|
this.txtField2.Location = new System.Drawing.Point(15, 82);
|
||||||
|
this.txtField2.Name = "txtField2";
|
||||||
|
this.txtField2.Size = new System.Drawing.Size(142, 20);
|
||||||
|
this.txtField2.TabIndex = 20;
|
||||||
|
//
|
||||||
|
// btnGetColumn2
|
||||||
|
//
|
||||||
|
this.btnGetColumn2.Location = new System.Drawing.Point(292, 80);
|
||||||
|
this.btnGetColumn2.Name = "btnGetColumn2";
|
||||||
|
this.btnGetColumn2.Size = new System.Drawing.Size(60, 23);
|
||||||
|
this.btnGetColumn2.TabIndex = 19;
|
||||||
|
this.btnGetColumn2.Text = "GetColumn";
|
||||||
|
this.btnGetColumn2.UseVisualStyleBackColor = true;
|
||||||
|
this.btnGetColumn2.Click += new System.EventHandler(this.btnGetColumn2_Click);
|
||||||
|
//
|
||||||
|
// btnHasText3
|
||||||
|
//
|
||||||
|
this.btnHasText3.Location = new System.Drawing.Point(163, 109);
|
||||||
|
this.btnHasText3.Name = "btnHasText3";
|
||||||
|
this.btnHasText3.Size = new System.Drawing.Size(57, 23);
|
||||||
|
this.btnHasText3.TabIndex = 26;
|
||||||
|
this.btnHasText3.Text = "HasText";
|
||||||
|
this.btnHasText3.UseVisualStyleBackColor = true;
|
||||||
|
this.btnHasText3.Click += new System.EventHandler(this.btnHasText3_Click);
|
||||||
|
//
|
||||||
|
// btnGetField3
|
||||||
|
//
|
||||||
|
this.btnGetField3.Location = new System.Drawing.Point(226, 109);
|
||||||
|
this.btnGetField3.Name = "btnGetField3";
|
||||||
|
this.btnGetField3.Size = new System.Drawing.Size(60, 23);
|
||||||
|
this.btnGetField3.TabIndex = 25;
|
||||||
|
this.btnGetField3.Text = "GetField";
|
||||||
|
this.btnGetField3.UseVisualStyleBackColor = true;
|
||||||
|
this.btnGetField3.Click += new System.EventHandler(this.btnGetField3_Click);
|
||||||
|
//
|
||||||
|
// txtField3
|
||||||
|
//
|
||||||
|
this.txtField3.Location = new System.Drawing.Point(15, 111);
|
||||||
|
this.txtField3.Name = "txtField3";
|
||||||
|
this.txtField3.Size = new System.Drawing.Size(142, 20);
|
||||||
|
this.txtField3.TabIndex = 24;
|
||||||
|
//
|
||||||
|
// btnGetColumn3
|
||||||
|
//
|
||||||
|
this.btnGetColumn3.Location = new System.Drawing.Point(292, 109);
|
||||||
|
this.btnGetColumn3.Name = "btnGetColumn3";
|
||||||
|
this.btnGetColumn3.Size = new System.Drawing.Size(60, 23);
|
||||||
|
this.btnGetColumn3.TabIndex = 23;
|
||||||
|
this.btnGetColumn3.Text = "GetColumn";
|
||||||
|
this.btnGetColumn3.UseVisualStyleBackColor = true;
|
||||||
|
this.btnGetColumn3.Click += new System.EventHandler(this.btnGetColumn3_Click);
|
||||||
|
//
|
||||||
// FrmPdfInfo
|
// FrmPdfInfo
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(484, 461);
|
this.ClientSize = new System.Drawing.Size(484, 461);
|
||||||
|
this.Controls.Add(this.btnHasText3);
|
||||||
|
this.Controls.Add(this.btnGetField3);
|
||||||
|
this.Controls.Add(this.txtField3);
|
||||||
|
this.Controls.Add(this.btnGetColumn3);
|
||||||
|
this.Controls.Add(this.btnHasText2);
|
||||||
|
this.Controls.Add(this.btnGetField2);
|
||||||
|
this.Controls.Add(this.txtField2);
|
||||||
|
this.Controls.Add(this.btnGetColumn2);
|
||||||
this.Controls.Add(this.btnRender);
|
this.Controls.Add(this.btnRender);
|
||||||
this.Controls.Add(this.txtText);
|
this.Controls.Add(this.btnHasText1);
|
||||||
this.Controls.Add(this.btnHasText);
|
this.Controls.Add(this.btnGetField1);
|
||||||
this.Controls.Add(this.txtFieldName);
|
this.Controls.Add(this.txtField1);
|
||||||
this.Controls.Add(this.btnGetField);
|
this.Controls.Add(this.btnGetColumn1);
|
||||||
this.Controls.Add(this.txtColumnName);
|
|
||||||
this.Controls.Add(this.btnGetColumn);
|
|
||||||
this.Controls.Add(this.lblOutputs);
|
this.Controls.Add(this.lblOutputs);
|
||||||
this.Controls.Add(this.lblInputs);
|
this.Controls.Add(this.lblInputs);
|
||||||
this.Controls.Add(this.btnBrowse);
|
this.Controls.Add(this.btnBrowse);
|
||||||
@@ -206,12 +278,18 @@
|
|||||||
private System.Windows.Forms.TextBox txtPdfPath;
|
private System.Windows.Forms.TextBox txtPdfPath;
|
||||||
private System.Windows.Forms.TextBox txtOutput;
|
private System.Windows.Forms.TextBox txtOutput;
|
||||||
private System.Windows.Forms.Button btnProcess;
|
private System.Windows.Forms.Button btnProcess;
|
||||||
private System.Windows.Forms.Button btnGetColumn;
|
private System.Windows.Forms.Button btnGetColumn1;
|
||||||
private System.Windows.Forms.TextBox txtColumnName;
|
private System.Windows.Forms.TextBox txtField1;
|
||||||
private System.Windows.Forms.TextBox txtFieldName;
|
private System.Windows.Forms.Button btnGetField1;
|
||||||
private System.Windows.Forms.Button btnGetField;
|
private System.Windows.Forms.Button btnHasText1;
|
||||||
private System.Windows.Forms.TextBox txtText;
|
|
||||||
private System.Windows.Forms.Button btnHasText;
|
|
||||||
private System.Windows.Forms.Button btnRender;
|
private System.Windows.Forms.Button btnRender;
|
||||||
|
private System.Windows.Forms.Button btnHasText2;
|
||||||
|
private System.Windows.Forms.Button btnGetField2;
|
||||||
|
private System.Windows.Forms.TextBox txtField2;
|
||||||
|
private System.Windows.Forms.Button btnGetColumn2;
|
||||||
|
private System.Windows.Forms.Button btnHasText3;
|
||||||
|
private System.Windows.Forms.Button btnGetField3;
|
||||||
|
private System.Windows.Forms.TextBox txtField3;
|
||||||
|
private System.Windows.Forms.Button btnGetColumn3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ using System.Drawing.Drawing2D;
|
|||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using VAR.PdfTools.PdfElements;
|
using VAR.PdfTools.PdfElements;
|
||||||
|
|
||||||
@@ -20,17 +21,17 @@ namespace VAR.PdfTools.Workbench
|
|||||||
private void FrmPdfInfo_Load(object sender, EventArgs e)
|
private void FrmPdfInfo_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
txtPdfPath.Text = Properties.Settings.Default.LastPdfPath;
|
txtPdfPath.Text = Properties.Settings.Default.LastPdfPath;
|
||||||
txtColumnName.Text = Properties.Settings.Default.LastColumnName;
|
txtField1.Text = Properties.Settings.Default.Field1;
|
||||||
txtFieldName.Text = Properties.Settings.Default.LastFieldName;
|
txtField2.Text = Properties.Settings.Default.Field2;
|
||||||
txtText.Text = Properties.Settings.Default.LastText;
|
txtField3.Text = Properties.Settings.Default.Field3;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FrmPdfInfo_FormClosing(object sender, FormClosingEventArgs e)
|
private void FrmPdfInfo_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
Properties.Settings.Default.LastPdfPath = txtPdfPath.Text;
|
Properties.Settings.Default.LastPdfPath = txtPdfPath.Text;
|
||||||
Properties.Settings.Default.LastColumnName = txtColumnName.Text;
|
Properties.Settings.Default.Field1 = txtField1.Text;
|
||||||
Properties.Settings.Default.LastFieldName = txtFieldName.Text;
|
Properties.Settings.Default.Field2 = txtField2.Text;
|
||||||
Properties.Settings.Default.LastText = txtText.Text;
|
Properties.Settings.Default.Field3 = txtField3.Text;
|
||||||
Properties.Settings.Default.Save();
|
Properties.Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,9 +93,25 @@ namespace VAR.PdfTools.Workbench
|
|||||||
PdfTextExtractor extractor = new PdfTextExtractor(page);
|
PdfTextExtractor extractor = new PdfTextExtractor(page);
|
||||||
foreach (PdfTextElement textElement in extractor.Elements)
|
foreach (PdfTextElement textElement in extractor.Elements)
|
||||||
{
|
{
|
||||||
|
string fontName = textElement.Font == null ? "#NULL#" : textElement.Font.Name;
|
||||||
|
if (fontName == "#NULL#" && textElement.Childs.Count > 0)
|
||||||
|
{
|
||||||
|
var fontNames = textElement.Childs.Select(c => c.Font == null ? "#NULL#" : c.Font.Name);
|
||||||
|
StringBuilder sbFontName = new StringBuilder();
|
||||||
|
foreach(string fontNameAux in fontNames)
|
||||||
|
{
|
||||||
|
if (sbFontName.Length > 0) { sbFontName.Append(";"); }
|
||||||
|
sbFontName.Append(fontNameAux);
|
||||||
|
}
|
||||||
|
fontName = sbFontName.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
lines.Add(string.Format("Text({0}, {1})({2}, {3})[{4}]: \"{5}\"",
|
lines.Add(string.Format("Text({0}, {1})({2}, {3})[{4}]: \"{5}\"",
|
||||||
textElement.Matrix.Matrix[0, 2], textElement.Matrix.Matrix[1, 2], textElement.VisibleWidth, textElement.VisibleHeight,
|
Math.Round(textElement.Matrix.Matrix[0, 2], 2),
|
||||||
textElement.Font == null ? "#NULL#" : textElement.Font.Name,
|
Math.Round(textElement.Matrix.Matrix[1, 2], 2),
|
||||||
|
Math.Round(textElement.VisibleWidth, 2),
|
||||||
|
Math.Round(textElement.VisibleHeight, 2),
|
||||||
|
fontName,
|
||||||
textElement.VisibleText));
|
textElement.VisibleText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,64 +119,136 @@ namespace VAR.PdfTools.Workbench
|
|||||||
txtOutput.Lines = lines.ToArray();
|
txtOutput.Lines = lines.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnGetColumn_Click(object sender, EventArgs e)
|
private void btnHasText1_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (System.IO.File.Exists(txtPdfPath.Text) == false)
|
string pdfPath = txtPdfPath.Text;
|
||||||
|
string text = txtField1.Text;
|
||||||
|
|
||||||
|
Action_HasText(pdfPath, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnGetField1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string pdfPath = txtPdfPath.Text;
|
||||||
|
string field = txtField1.Text;
|
||||||
|
|
||||||
|
Action_GetField(pdfPath, field);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnGetColumn1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string pdfPath = txtPdfPath.Text;
|
||||||
|
string column = txtField1.Text;
|
||||||
|
|
||||||
|
Action_GetColumn(pdfPath, column);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnHasText2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string pdfPath = txtPdfPath.Text;
|
||||||
|
string text = txtField2.Text;
|
||||||
|
|
||||||
|
Action_HasText(pdfPath, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnGetField2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string pdfPath = txtPdfPath.Text;
|
||||||
|
string field = txtField2.Text;
|
||||||
|
|
||||||
|
Action_GetField(pdfPath, field);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnGetColumn2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string pdfPath = txtPdfPath.Text;
|
||||||
|
string column = txtField2.Text;
|
||||||
|
|
||||||
|
Action_GetColumn(pdfPath, column);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnHasText3_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string pdfPath = txtPdfPath.Text;
|
||||||
|
string text = txtField3.Text;
|
||||||
|
|
||||||
|
Action_HasText(pdfPath, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnGetField3_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string pdfPath = txtPdfPath.Text;
|
||||||
|
string field = txtField3.Text;
|
||||||
|
|
||||||
|
Action_GetField(pdfPath, field);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnGetColumn3_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string pdfPath = txtPdfPath.Text;
|
||||||
|
string column = txtField3.Text;
|
||||||
|
|
||||||
|
Action_GetColumn(pdfPath, column);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Action_HasText(string pdfPath, string text)
|
||||||
|
{
|
||||||
|
if (System.IO.File.Exists(pdfPath) == false)
|
||||||
{
|
{
|
||||||
MessageBox.Show("File does not exist");
|
MessageBox.Show("File does not exist");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PdfDocument doc = PdfDocument.Load(txtPdfPath.Text);
|
PdfDocument doc = PdfDocument.Load(pdfPath);
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnHasText_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);
|
|
||||||
|
|
||||||
List<string> lines = new List<string>();
|
List<string> lines = new List<string>();
|
||||||
int pageNum = 1;
|
int pageNum = 1;
|
||||||
foreach (PdfDocumentPage page in doc.Pages)
|
foreach (PdfDocumentPage page in doc.Pages)
|
||||||
{
|
{
|
||||||
PdfTextExtractor extractor = new PdfTextExtractor(page);
|
PdfTextExtractor extractor = new PdfTextExtractor(page);
|
||||||
lines.Add(string.Format("Page({0}) : {1}", pageNum, Convert.ToString(extractor.HasText(txtText.Text))));
|
lines.Add(string.Format("Page({0}) : {1}", pageNum, Convert.ToString(extractor.HasText(text))));
|
||||||
}
|
}
|
||||||
txtOutput.Lines = lines.ToArray();
|
txtOutput.Lines = lines.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Action_GetField(string pdfPath, string field)
|
||||||
|
{
|
||||||
|
if (System.IO.File.Exists(pdfPath) == false)
|
||||||
|
{
|
||||||
|
MessageBox.Show("File does not exist");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PdfDocument doc = PdfDocument.Load(pdfPath);
|
||||||
|
|
||||||
|
var fieldData = new List<string>();
|
||||||
|
foreach (PdfDocumentPage page in doc.Pages)
|
||||||
|
{
|
||||||
|
PdfTextExtractor extractor = new PdfTextExtractor(page);
|
||||||
|
fieldData.Add(extractor.GetField(field));
|
||||||
|
}
|
||||||
|
txtOutput.Lines = fieldData.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Action_GetColumn(string pdfPath, string column)
|
||||||
|
{
|
||||||
|
if (System.IO.File.Exists(pdfPath) == false)
|
||||||
|
{
|
||||||
|
MessageBox.Show("File does not exist");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PdfDocument doc = PdfDocument.Load(pdfPath);
|
||||||
|
|
||||||
|
var columnData = new List<string>();
|
||||||
|
foreach (PdfDocumentPage page in doc.Pages)
|
||||||
|
{
|
||||||
|
PdfTextExtractor extractor = new PdfTextExtractor(page);
|
||||||
|
columnData.AddRange(extractor.GetColumn(column));
|
||||||
|
}
|
||||||
|
txtOutput.Lines = columnData.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
private void btnRender_Click(object sender, EventArgs e)
|
private void btnRender_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (File.Exists(txtPdfPath.Text) == false)
|
if (File.Exists(txtPdfPath.Text) == false)
|
||||||
@@ -168,7 +257,7 @@ namespace VAR.PdfTools.Workbench
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int Scale = 5;
|
int MaxSize = 10000;
|
||||||
|
|
||||||
PdfDocument doc = PdfDocument.Load(txtPdfPath.Text);
|
PdfDocument doc = PdfDocument.Load(txtPdfPath.Text);
|
||||||
string baseDocumentPath = Path.GetDirectoryName(txtPdfPath.Text);
|
string baseDocumentPath = Path.GetDirectoryName(txtPdfPath.Text);
|
||||||
@@ -205,6 +294,10 @@ namespace VAR.PdfTools.Workbench
|
|||||||
// Prepare page image
|
// Prepare page image
|
||||||
int pageWidth = (int)Math.Ceiling(pageXMax - pageXMin);
|
int pageWidth = (int)Math.Ceiling(pageXMax - pageXMin);
|
||||||
int pageHeight = (int)Math.Ceiling(pageYMax - pageYMin);
|
int pageHeight = (int)Math.Ceiling(pageYMax - pageYMin);
|
||||||
|
int Scale = 10;
|
||||||
|
while ((pageWidth * Scale) > MaxSize) { Scale--; }
|
||||||
|
while ((pageHeight * Scale) > MaxSize) { Scale--; }
|
||||||
|
if (Scale <= 0) { Scale = 1; }
|
||||||
using (Bitmap bmp = new Bitmap(pageWidth * Scale, pageHeight * Scale, PixelFormat.Format32bppArgb))
|
using (Bitmap bmp = new Bitmap(pageWidth * Scale, pageHeight * Scale, PixelFormat.Format32bppArgb))
|
||||||
using (Graphics gc = Graphics.FromImage(bmp))
|
using (Graphics gc = Graphics.FromImage(bmp))
|
||||||
using (Pen penTextElem = new Pen(Color.Blue))
|
using (Pen penTextElem = new Pen(Color.Blue))
|
||||||
@@ -246,8 +339,7 @@ namespace VAR.PdfTools.Workbench
|
|||||||
(int)(textElementPageY * Scale),
|
(int)(textElementPageY * Scale),
|
||||||
(int)(textElementWidth * Scale),
|
(int)(textElementWidth * Scale),
|
||||||
(int)(textElementHeight * Scale),
|
(int)(textElementHeight * Scale),
|
||||||
Scale);
|
5);
|
||||||
|
|
||||||
|
|
||||||
using (Font font = new Font("Arial", (int)(textElementHeight * Scale), GraphicsUnit.Pixel))
|
using (Font font = new Font("Arial", (int)(textElementHeight * Scale), GraphicsUnit.Pixel))
|
||||||
{
|
{
|
||||||
@@ -262,6 +354,10 @@ namespace VAR.PdfTools.Workbench
|
|||||||
(int)((textElementPageX + c.Displacement) * Scale),
|
(int)((textElementPageX + c.Displacement) * Scale),
|
||||||
(int)(textElementPageY * Scale),
|
(int)(textElementPageY * Scale),
|
||||||
2, 2);
|
2, 2);
|
||||||
|
gc.FillRectangle(Brushes.Green,
|
||||||
|
(int)((textElementPageX + c.Displacement + c.Width) * Scale),
|
||||||
|
(int)(textElementPageY * Scale),
|
||||||
|
2, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
120
VAR.PdfTools.Workbench/FrmPdfInfo.resx
Normal file
120
VAR.PdfTools.Workbench/FrmPdfInfo.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?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>
|
||||||
@@ -11,4 +11,4 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
[assembly: Guid("a5825d8e-9f81-49e0-b610-8ae5e46d02ea")]
|
[assembly: Guid("a5825d8e-9f81-49e0-b610-8ae5e46d02ea")]
|
||||||
[assembly: AssemblyVersion("1.4.0.*")]
|
[assembly: AssemblyVersion("1.5.0.*")]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace VAR.PdfTools.Workbench.Properties {
|
|||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
@@ -38,36 +38,36 @@ namespace VAR.PdfTools.Workbench.Properties {
|
|||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
public string LastColumnName {
|
public string Field1 {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["LastColumnName"]));
|
return ((string)(this["Field1"]));
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
this["LastColumnName"] = value;
|
this["Field1"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
public string LastFieldName {
|
public string Field2 {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["LastFieldName"]));
|
return ((string)(this["Field2"]));
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
this["LastFieldName"] = value;
|
this["Field2"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
public string LastText {
|
public string Field3 {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["LastText"]));
|
return ((string)(this["Field3"]));
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
this["LastText"] = value;
|
this["Field3"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
<Setting Name="LastPdfPath" Type="System.String" Scope="User">
|
<Setting Name="LastPdfPath" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)" />
|
<Value Profile="(Default)" />
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="LastColumnName" Type="System.String" Scope="User">
|
<Setting Name="Field1" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)" />
|
<Value Profile="(Default)" />
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="LastFieldName" Type="System.String" Scope="User">
|
<Setting Name="Field2" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)" />
|
<Value Profile="(Default)" />
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="LastText" Type="System.String" Scope="User">
|
<Setting Name="Field3" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)" />
|
<Value Profile="(Default)" />
|
||||||
</Setting>
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<None Include="app.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
@@ -71,6 +72,11 @@
|
|||||||
<Name>VAR.PdfTools</Name>
|
<Name>VAR.PdfTools</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="FrmPdfInfo.resx">
|
||||||
|
<DependentUpon>FrmPdfInfo.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- 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.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
24
VAR.PdfTools.Workbench/app.config
Normal file
24
VAR.PdfTools.Workbench/app.config
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?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>
|
||||||
|
<userSettings>
|
||||||
|
<VAR.PdfTools.Workbench.Properties.Settings>
|
||||||
|
<setting name="LastPdfPath" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
|
<setting name="Field1" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
|
<setting name="Field2" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
|
<setting name="Field3" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
|
</VAR.PdfTools.Workbench.Properties.Settings>
|
||||||
|
</userSettings>
|
||||||
|
</configuration>
|
||||||
@@ -87,7 +87,9 @@ namespace VAR.PdfTools
|
|||||||
char actualChar = firstChar;
|
char actualChar = firstChar;
|
||||||
foreach (IPdfElement elem in widths.Values)
|
foreach (IPdfElement elem in widths.Values)
|
||||||
{
|
{
|
||||||
_widths.Add(actualChar, PdfElementUtils.GetReal(elem, 500) / glyphSpaceToTextSpace);
|
double width = PdfElementUtils.GetReal(elem, 500);
|
||||||
|
if (width < 0.0001f && width > -0.0001f) { width = 500; }
|
||||||
|
_widths.Add(actualChar, width / glyphSpaceToTextSpace);
|
||||||
actualChar++;
|
actualChar++;
|
||||||
}
|
}
|
||||||
// FIMXE: Calculate real height
|
// FIMXE: Calculate real height
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace VAR.PdfTools
|
|||||||
{
|
{
|
||||||
public string Char;
|
public string Char;
|
||||||
public double Displacement;
|
public double Displacement;
|
||||||
|
public double Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PdfTextElement
|
public class PdfTextElement
|
||||||
@@ -49,6 +50,41 @@ namespace VAR.PdfTools
|
|||||||
return Matrix.Matrix[1, 2];
|
return Matrix.Matrix[1, 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PdfTextElement SubPart(int startIndex, int endIndex)
|
||||||
|
{
|
||||||
|
PdfTextElement blockElem = new PdfTextElement
|
||||||
|
{
|
||||||
|
Font = null,
|
||||||
|
FontSize = FontSize,
|
||||||
|
Matrix = Matrix.Copy(),
|
||||||
|
RawText = RawText.Substring(startIndex, endIndex - startIndex),
|
||||||
|
VisibleText = VisibleText.Substring(startIndex, endIndex - startIndex),
|
||||||
|
VisibleWidth = 0,
|
||||||
|
VisibleHeight = VisibleHeight,
|
||||||
|
Characters = new List<PdfCharElement>(),
|
||||||
|
Childs = new List<PdfTextElement>(),
|
||||||
|
};
|
||||||
|
double displacement = Characters[startIndex].Displacement;
|
||||||
|
blockElem.Matrix.Matrix[0, 2] += displacement;
|
||||||
|
for (int j = startIndex; j < endIndex; j++)
|
||||||
|
{
|
||||||
|
blockElem.Characters.Add(new PdfCharElement
|
||||||
|
{
|
||||||
|
Char = Characters[j].Char,
|
||||||
|
Displacement = Characters[j].Displacement - displacement,
|
||||||
|
Width = Characters[j].Width,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
PdfCharElement lastChar = blockElem.Characters[blockElem.Characters.Count - 1];
|
||||||
|
blockElem.VisibleWidth = lastChar.Displacement + lastChar.Width;
|
||||||
|
foreach (PdfTextElement elem in Childs)
|
||||||
|
{
|
||||||
|
blockElem.Childs.Add(elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return blockElem;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +132,7 @@ namespace VAR.PdfTools
|
|||||||
_page = page;
|
_page = page;
|
||||||
ProcessPageContent();
|
ProcessPageContent();
|
||||||
JoinTextElements();
|
JoinTextElements();
|
||||||
|
SplitTextElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -125,7 +162,8 @@ namespace VAR.PdfTools
|
|||||||
textElem.Matrix = _textMatrixCurrent.Multiply(_graphicsMatrix);
|
textElem.Matrix = _textMatrixCurrent.Multiply(_graphicsMatrix);
|
||||||
textElem.RawText = _sbText.ToString();
|
textElem.RawText = _sbText.ToString();
|
||||||
textElem.VisibleText = PdfString_ToUnicode(textElem.RawText, _font);
|
textElem.VisibleText = PdfString_ToUnicode(textElem.RawText, _font);
|
||||||
textElem.VisibleWidth = _textWidth * textElem.Matrix.Matrix[0, 0];
|
PdfCharElement lastChar = _listCharacters[_listCharacters.Count - 1];
|
||||||
|
textElem.VisibleWidth = (lastChar.Displacement + lastChar.Width) * textElem.Matrix.Matrix[0, 0];
|
||||||
textElem.VisibleHeight = (_font.Height * _fontSize) * textElem.Matrix.Matrix[1, 1];
|
textElem.VisibleHeight = (_font.Height * _fontSize) * textElem.Matrix.Matrix[1, 1];
|
||||||
textElem.Characters = new List<PdfCharElement>();
|
textElem.Characters = new List<PdfCharElement>();
|
||||||
foreach (PdfCharElement c in _listCharacters)
|
foreach (PdfCharElement c in _listCharacters)
|
||||||
@@ -134,6 +172,7 @@ namespace VAR.PdfTools
|
|||||||
{
|
{
|
||||||
Char = c.Char,
|
Char = c.Char,
|
||||||
Displacement = (c.Displacement * textElem.Matrix.Matrix[0, 0]),
|
Displacement = (c.Displacement * textElem.Matrix.Matrix[0, 0]),
|
||||||
|
Width = (c.Width * textElem.Matrix.Matrix[0, 0]),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
textElem.Childs = new List<PdfTextElement>();
|
textElem.Childs = new List<PdfTextElement>();
|
||||||
@@ -320,8 +359,8 @@ namespace VAR.PdfTools
|
|||||||
{
|
{
|
||||||
string realChar = _font.ToUnicode(c);
|
string realChar = _font.ToUnicode(c);
|
||||||
if (realChar == "\0") { continue; }
|
if (realChar == "\0") { continue; }
|
||||||
_listCharacters.Add(new PdfCharElement { Char = _font.ToUnicode(c), Displacement = _textWidth, });
|
|
||||||
double charWidth = _font.GetCharWidth(c) * _fontSize;
|
double charWidth = _font.GetCharWidth(c) * _fontSize;
|
||||||
|
_listCharacters.Add(new PdfCharElement { Char = _font.ToUnicode(c), Displacement = _textWidth, Width = charWidth });
|
||||||
_textWidth += charWidth;
|
_textWidth += charWidth;
|
||||||
_textWidth += ((c == 0x20) ? _wordSpacing : _charSpacing);
|
_textWidth += ((c == 0x20) ? _wordSpacing : _charSpacing);
|
||||||
}
|
}
|
||||||
@@ -356,6 +395,9 @@ namespace VAR.PdfTools
|
|||||||
private void ProcessPageContent()
|
private void ProcessPageContent()
|
||||||
{
|
{
|
||||||
int unknowCount = 0;
|
int unknowCount = 0;
|
||||||
|
int lineCount = 0;
|
||||||
|
int strokeCount = 0;
|
||||||
|
int pathCount = 0;
|
||||||
for (int i = 0; i < _page.ContentActions.Count; i++)
|
for (int i = 0; i < _page.ContentActions.Count; i++)
|
||||||
{
|
{
|
||||||
PdfContentAction action = _page.ContentActions[i];
|
PdfContentAction action = _page.ContentActions[i];
|
||||||
@@ -513,6 +555,45 @@ namespace VAR.PdfTools
|
|||||||
{
|
{
|
||||||
// FIXME: Interpret this
|
// FIXME: Interpret this
|
||||||
}
|
}
|
||||||
|
else if (action.Token == "m")
|
||||||
|
{
|
||||||
|
// FIXME: Interpret this "moveto: Begin new subpath"
|
||||||
|
}
|
||||||
|
else if (action.Token == "l")
|
||||||
|
{
|
||||||
|
// FIXME: Interpret this "lineto: Append straight line segment to path"
|
||||||
|
lineCount++;
|
||||||
|
}
|
||||||
|
else if (action.Token == "h")
|
||||||
|
{
|
||||||
|
// FIXME: Interpret this "closepath: Close subpath"
|
||||||
|
pathCount++;
|
||||||
|
}
|
||||||
|
else if (action.Token == "W")
|
||||||
|
{
|
||||||
|
// FIXME: Interpret this "clip: Set clipping path using nonzero winding number rule"
|
||||||
|
}
|
||||||
|
else if (action.Token == "W*")
|
||||||
|
{
|
||||||
|
// FIXME: Interpret this "eoclip: Set clipping path using even-odd rule"
|
||||||
|
}
|
||||||
|
else if (action.Token == "w")
|
||||||
|
{
|
||||||
|
// FIXME: Interpret this "setlinewidth: Set line width"
|
||||||
|
}
|
||||||
|
else if (action.Token == "G")
|
||||||
|
{
|
||||||
|
// FIXME: Interpret this "setgray: Set gray level for stroking operations"
|
||||||
|
}
|
||||||
|
else if (action.Token == "S")
|
||||||
|
{
|
||||||
|
// FIXME: Interpret this "stroke: Stroke path"
|
||||||
|
strokeCount++;
|
||||||
|
}
|
||||||
|
else if (action.Token == "M")
|
||||||
|
{
|
||||||
|
// FIXME: Interpret this "setmiterlimit: Set miter limit"
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unknowCount++;
|
unknowCount++;
|
||||||
@@ -577,6 +658,7 @@ namespace VAR.PdfTools
|
|||||||
{
|
{
|
||||||
Char = c.Char,
|
Char = c.Char,
|
||||||
Displacement = (c.Displacement + neighbourXMin) - blockXMin,
|
Displacement = (c.Displacement + neighbourXMin) - blockXMin,
|
||||||
|
Width = c.Width,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -604,6 +686,38 @@ namespace VAR.PdfTools
|
|||||||
_textElements = textElementsCondensed;
|
_textElements = textElementsCondensed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SplitTextElements()
|
||||||
|
{
|
||||||
|
var textElementsSplitted = new List<PdfTextElement>();
|
||||||
|
while (_textElements.Count > 0)
|
||||||
|
{
|
||||||
|
PdfTextElement elem = _textElements[0];
|
||||||
|
_textElements.Remove(elem);
|
||||||
|
|
||||||
|
int prevBreak = 0;
|
||||||
|
for (int i = 1; i < elem.Characters.Count; i++)
|
||||||
|
{
|
||||||
|
double prevCharEnd = elem.Characters[i - 1].Displacement + elem.Characters[i - 1].Width;
|
||||||
|
double charSeparation = elem.Characters[i].Displacement - prevCharEnd;
|
||||||
|
if (charSeparation > (elem.Characters[i - 1].Width * 2))
|
||||||
|
{
|
||||||
|
PdfTextElement partElem = elem.SubPart(prevBreak, i);
|
||||||
|
textElementsSplitted.Add(partElem);
|
||||||
|
prevBreak = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prevBreak == 0)
|
||||||
|
{
|
||||||
|
textElementsSplitted.Add(elem);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
PdfTextElement lastElem = elem.SubPart(prevBreak, elem.Characters.Count);
|
||||||
|
textElementsSplitted.Add(lastElem);
|
||||||
|
}
|
||||||
|
_textElements = textElementsSplitted;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public methods
|
#region Public methods
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
[assembly: Guid("eb7e003a-6a95-4002-809f-926c7c8a11e9")]
|
[assembly: Guid("eb7e003a-6a95-4002-809f-926c7c8a11e9")]
|
||||||
[assembly: AssemblyVersion("1.4.0.*")]
|
[assembly: AssemblyVersion("1.5.0.*")]
|
||||||
|
|||||||
Reference in New Issue
Block a user