forked from SergiyStoyan/PdfDocumentParser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplate.cs
144 lines (123 loc) · 4.04 KB
/
Template.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//********************************************************************************************
//Author: Sergiy Stoyan
// s.y.stoyan@gmail.com, sergiy.stoyan@outlook.com, stoyan@cliversoft.com
// http://www.cliversoft.com
//********************************************************************************************
using System;
using System.Collections.Generic;
namespace Cliver.PdfDocumentParser
{
/// <summary>
/// parsing rules corresponding to certain pdf document layout
/// </summary>
public partial class Template
{
public class EditorSettings
{
public bool ExtractFieldsAutomaticallyWhenPageChanged = true;
public bool ShowFieldTextLineSeparators = true;
public bool CheckConditionsAutomaticallyWhenPageChanged = true;
public decimal TestPictureScale = 1.2m;
}
public EditorSettings Editor;
public string Name;
[Newtonsoft.Json.JsonConverter(typeof(Serialization.Json.NoIndentConverter))]
public TextAutoInsertSpace TextAutoInsertSpace = new TextAutoInsertSpace();
//public bool IgnoreDuplicatedPdfChars = true;//used but not edited
public List<Anchor> Anchors;
public List<Condition> Conditions;
public List<Field> Fields;
public bool IsField(string fieldName)
{
return null != Fields.Find(a => a.Name == fieldName);
}
public class RectangleF
{
public float X;
public float Y;
public float Width;
public float Height;
public RectangleF(float x, float y, float w, float h)
{
X = x;
Y = y;
Width = w;
Height = h;
}
static public RectangleF GetFromSystemRectangleF(System.Drawing.RectangleF r)
{
return new RectangleF(r.X, r.Y, r.Width, r.Height);
}
public System.Drawing.Rectangle GetSystemRectangle()
{
return new System.Drawing.Rectangle((int)Math.Round(X, 0), (int)Math.Round(Y, 0), (int)Math.Round(Width, 0), (int)Math.Round(Height, 0));
}
public System.Drawing.RectangleF GetSystemRectangleF()
{
return new System.Drawing.RectangleF(X, Y, Width, Height);
}
}
public class PointF
{
public float X;
public float Y;
}
public class SizeF
{
public float Width;
public float Height;
}
public class Size
{
public int Width;
public int Height;
}
public class Condition
{
public string Name;
public string Value;
public bool IsSet()
{
return !string.IsNullOrWhiteSpace(Name) && !string.IsNullOrWhiteSpace(Value);
}
}
}
public class CharFilter
{
public float MinWidth;
//{
// get { return minWidth; }
// set { minWidth = value > 0 ? value : 0; }
//}
//float minWidth;
public float MaxWidth;
//{
// get { return maxWidth; }
// set { maxWidth = value > 0 ? value : 0; }
//}
//float maxWidth;
public float MinHeight;
//{
// get { return minHeight; }
// set { minHeight = value > 0 ? value : 0; }
//}
//float minHeight;
public float MaxHeight;
//{
// get { return maxHeight; }
// set { maxHeight = value > 0 ? value : 0; }
//}
//float maxHeight;
public override string ToString()//used only by debugging tips
{
return this.ToStringByJson();
}
}
public class TextAutoInsertSpace
{
public float Threshold = 6;
public string Representative = " ";
//public string Substitute = " ";
public bool IgnoreSourceSpaces = false;
}
}