-
Notifications
You must be signed in to change notification settings - Fork 1
/
Sample25.cs
216 lines (200 loc) · 14.4 KB
/
Sample25.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
using System.Diagnostics;
using iTin.Core.ComponentModel;
using iTin.Logging.ComponentModel;
using iPdfWriter.Operations.Actions;
namespace iPdfWriter.ConsoleApp.Code
{
/// <summary>
/// Show how to creates a pdf input from html
/// </summary>
internal static class Sample25
{
// Generates document
public static void Generate(ILogger logger)
{
#region Initialize timer
var sw = new Stopwatch();
sw.Start();
#endregion
#region Creates pdf input
var doc = PdfInput.CreateFromHtml(
html: @"
<div>
<p style='font-size:26pt; font-family:Arial; text-align: center;'><strong>#TITLE#</strong></p>
</div>
<div style='font-size:10.5pt; font-family:Arial; text-align: left;'>
<p style='font-size:18pt; font-family:Arial; text-align: left;'><strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ac faucibus odio.</strong></p>
<p>
Vestibulum neque massa, scelerisque sit amet ligula eu, congue molestie mi. Praesent ut varius sem. Nullam at porttitor arcu, nec lacinia nisi. Ut ac dolor vitae odio interdum condimentum.
<strong>Vivamus dapibus sodales ex, vitae malesuada ipsum cursus convallis. Maecenas sed egestas nulla, ac condimentum orci.</strong> Mauris diam felis, vulputate ac suscipit et, iaculis non est.
Curabitur semper arcu ac ligula semper, nec luctus nisl blandit. Integer lacinia ante ac libero lobortis imperdiet. Nullam mollis convallis ipsum, ac accumsan nunc vehicula vitae.
Nulla eget justo in felis tristique fringilla. Morbi sit amet tortor quis risus auctor condimentum. Morbi in ullamcorper elit. Nulla iaculis tellus sit amet mauris tempus fringilla
</p>
<p>Maecenas mauris lectus, lobortis et purus mattis, blandit dictum tellus.</p>
<p>
<ul>
<li><strong>Maecenas non lorem quis tellus placerat varius.</strong></li>
<li><em>Nulla facilisi.</em></li>
<li style='text-decoration: underline;'>Aenean congue fringilla justo ut aliquam.</li>
<li><span style='text-decoration: underline;'>Mauris id ex erat.</span> Nunc vulputate neque vitae justo facilisis, non condimentum ante sagittis.</li>
<li>Morbi viverra semper lorem nec molestie</li>
<li>Maecenas tincidunt est efficitur ligula euismod, sit amet ornare est vulputate</li>
</ul>
</p>
</div>
<div style='height: 420px;'>
<p style='font-size:12pt; font-family:Arial; text-align: left;'>#BAR-CHART#</p>
</div>
<div style='font-size:10.5pt; font-family:Arial; text-align: left;'>
<p>
In non mauris justo. Duis vehicula mi vel mi pretium, a viverra erat efficitur. Cras aliquam est ac eros
varius, id iaculis dui auctor. Duis pretium neque ligula, et pulvinar mi placerat et. Nulla nec nunc sit
amet nunc posuere vestibulum. Ut id neque eget tortor mattis tristique. Donec ante est, blandit sit amet
tristique vel, lacinia pulvinar arcu. Pellentesque scelerisque fermentum erat, id posuere justo pulvinar
ut. Cras id eros sed enim aliquam lobortis. Sed lobortis nisl ut eros efficitur tincidunt. Cras justo mi,
porttitor quis mattis vel, ultricies ut purus. Ut facilisis et lacus eu cursus.
</p>
<p>
In eleifend velit vitae libero sollicitudin euismod. Fusce vitae vestibulum velit. Pellentesque vulputate
lectus quis pellentesque commodo. Aliquam erat volutpat. Vestibulum in egestas velit. Pellentesque
fermentum nisl vitae fringilla venenatis. Etiam id mauris vitae orci maximus ultricies.
</p>
</div>
<div>
<p style='font-size:18pt; font-family:Arial; text-align: left;'><strong>Cras fringilla ipsum magna, in fringilla dui commodo a.</strong></p>
</div>
<div style='font-size:10.5pt; font-family:Arial; text-align: left;'>
<table border='1' cellspacing='0' cellpadding='6' style='width:100%'>
<tbody>
<tr style='font-size:10.5pt; font-family:Arial; color:#404040; text-align: left;'>
<td> </td>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr style='font-size:10.5pt; font-family:Arial; color:#404040; text-align: left;'>
<td>1</td>
<td>In eleifend velit vitae libero sollicitudin euismod.</td>
<td>Lorem</td>
<td> </td>
</tr>
<tr style='font-size:10.5pt; font-family:Arial; color:#404040; text-align: left;'>
<td>2</td>
<td>Cras fringilla ipsum magna, in fringilla dui commodo a.</td>
<td>Lorem</td>
<td> </td>
</tr>
<tr style='font-size:10.5pt; font-family:Arial; color:#404040; text-align: left;'>
<td>3</td>
<td>LAliquam erat volutpat.</td>
<td>Lorem</td>
<td> </td>
</tr>
<tr style='font-size:10.5pt; font-family:Arial; color:#404040; text-align: left;'>
<td>4</td>
<td>Fusce vitae vestibulum velit. </td>
<td>Lorem</td>
<td> </td>
</tr>
<tr style='font-size:10.5pt; font-family:Arial; color:#404040; text-align: left;'>
<td>5</td>
<td>Etiam vehicula luctus fermentum.</td>
<td>Ipsum</td>
<td> </td>
</tr>
</tbody>
</table>
</div>
<div style='font-size:10.5pt; font-family:Arial; text-align: left;'>
<p>
Etiam vehicula luctus fermentum. In vel metus congue, pulvinar lectus vel, fermentum dui. Maecenas
ante orci, egestas ut aliquet sit amet, sagittis a magna. Aliquam ante quam, pellentesque ut dignissim
quis, laoreet eget est. Aliquam erat volutpat. Class aptent taciti sociosqu ad litora torquent per conubia
nostra, per inceptos himenaeos. Ut ullamcorper justo sapien, in cursus libero viverra eget. Vivamus
auctor imperdiet urna, at pulvinar leo posuere laoreet. Suspendisse neque nisl, fringilla at iaculis
scelerisque, ornare vel dolor. Ut et pulvinar nunc. Pellentesque fringilla mollis efficitur. Nullam venenatis
commodo imperdiet. Morbi velit neque, semper quis lorem quis, efficitur dignissim ipsum. Ut ac lorem
sed turpis imperdiet eleifend sit amet id sapien
</p>
</div>
<div style='font-size:10.5pt; font-family:Arial; text-align: left;'>
<p style='font-size:18pt; font-family:Arial; text-align: left;'><strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</strong></p>
<p>
Nunc ac faucibus odio. Vestibulum neque massa, scelerisque sit amet ligula eu, congue molestie mi.
Praesent ut varius sem. Nullam at porttitor arcu, nec lacinia nisi. Ut ac dolor vitae odio interdum
condimentum. Vivamus dapibus sodales ex, vitae malesuada ipsum cursus convallis. Maecenas sed
egestas nulla, ac condimentum orci. Mauris diam felis, vulputate ac suscipit et, iaculis non est.
Curabitur semper arcu ac ligula semper, nec luctus nisl blandit. Integer lacinia ante ac libero lobortis
imperdiet. Nullam mollis convallis ipsum, ac accumsan nunc vehicula vitae. Nulla eget justo in felis
tristique fringilla. Morbi sit amet tortor quis risus auctor condimentum. Morbi in ullamcorper elit. Nulla
iaculis tellus sit amet mauris tempus fringilla.
</p>
</div>
<div style='font-size:10.5pt; font-family:Arial; text-align: left;'>
<p style='font-size:18pt; font-family:Arial; text-align: left;'><strong>Maecenas mauris lectus, lobortis et purus mattis, blandit dictum tellus.</strong></p>
<p>
Maecenas non lorem quis tellus placerat varius. Nulla facilisi. Aenean congue fringilla justo ut aliquam.
Mauris id ex erat. Nunc vulputate neque vitae justo facilisis, non condimentum ante sagittis. Morbi
viverra semper lorem nec molestie. Maecenas tincidunt est efficitur ligula euismod, sit amet ornare est
vulputate.
</p>
<p>
In non mauris justo. Duis vehicula mi vel mi pretium, a viverra erat efficitur. Cras aliquam est ac eros
varius, id iaculis dui auctor. Duis pretium neque ligula, et pulvinar mi placerat et. Nulla nec nunc sit
amet nunc posuere vestibulum. Ut id neque eget tortor mattis tristique. Donec ante est, blandit sit amet
tristique vel, lacinia pulvinar arcu. Pellentesque scelerisque fermentum erat, id posuere justo pulvinar
ut. Cras id eros sed enim aliquam lobortis. Sed lobortis nisl ut eros efficitur tincidunt. Cras justo mi,
porttitor quis mattis vel, ultricies ut purus. Ut facilisis et lacus eu cursus.
</p>
</div>
<div style='height: 1000px; font-size:10.5pt; font-family:Arial; text-align: left;'>
<p style='font-size:18pt; font-family:Arial; text-align: left;'><strong>In eleifend velit vitae libero sollicitudin euismod.</strong></p>
<p>
Fusce vitae vestibulum velit. Pellentesque vulputate lectus quis pellentesque commodo. Aliquam erat
volutpat. Vestibulum in egestas velit. Pellentesque fermentum nisl vitae fringilla venenatis. Etiam id
mauris vitae orci maximus ultricies. Cras fringilla ipsum magna, in fringilla dui commodo a.
</p>
<p>
Etiam vehicula luctus fermentum. In vel metus congue, pulvinar lectus vel, fermentum dui. Maecenas
ante orci, egestas ut aliquet sit amet, sagittis a magna. Aliquam ante quam, pellentesque ut dignissim
quis, laoreet eget est. Aliquam erat volutpat. Class aptent taciti sociosqu ad litora torquent per conubia
nostra, per inceptos himenaeos. Ut ullamcorper justo sapien, in cursus libero viverra eget. Vivamus
auctor imperdiet urna, at pulvinar leo posuere laoreet. Suspendisse neque nisl, fringilla at iaculis
scelerisque, ornare vel dolor. Ut et pulvinar nunc. Pellentesque fringilla mollis efficitur. Nullam venenatis
commodo imperdiet. Morbi velit neque, semper quis lorem quis, efficitur dignissim ipsum. Ut ac lorem
sed turpis imperdiet eleifend sit amet id sapien.
</p>
</div>
<p style='page-break-after: always'></p>
<br>
<div>
<p style='font-size:12pt; font-family:Arial; text-align: left;'>#IMAGE1#</p>
</div>");
#endregion
#region Create output result
var result = doc.CreateResult();
if (!result.Success)
{
logger.Info(" > Error creating output result");
logger.Info($" > Error: {result.Errors.AsMessages().ToStringBuilder()}");
return;
}
#endregion
#region Saves output result
var saveResult = result.Result.Action(new SaveToFile { OutputPath = "~/Output/Sample25/Sample-25" });
var ts = sw.Elapsed;
sw.Stop();
if (!saveResult.Success)
{
logger.Info(" > Error while saving to disk");
logger.Info($" > Error: {saveResult.Errors.AsMessages().ToStringBuilder()}");
return;
}
logger.Info(" > Saved to disk correctly");
logger.Info(" > Path: ~/Output/Sample25/Sample-25.pdf");
logger.Info($" > Elapsed time: {ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds / 10:00}");
#endregion
}
}
}