-
Notifications
You must be signed in to change notification settings - Fork 6
/
PdfixSamples.cs
162 lines (125 loc) · 6.47 KB
/
PdfixSamples.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
using PDFixSDK.Pdfix;
using System;
namespace PDFix.App.Module
{
class PdfixSamples
{
public static void Run(string rootPath)
{
string inputPath = Utils.GetAbsolutePath(rootPath + "res/");
string outputPath = Utils.GetAbsolutePath("output");
string configPath = "";
System.IO.Directory.CreateDirectory(outputPath);
//////////////////////////////////////////////////////////////////////
// Samples Free version - no authorization
//////////////////////////////////////////////////////////////////////
Console.WriteLine("Initialization");
Initialization.Run("", "");
Console.WriteLine("OpenFileFromStream Sample");
OpenFileFromStream.Run(inputPath + "test.pdf");
Console.WriteLine("OpenFileFromAzureStorage Sample");
Console.WriteLine("To run this sample please install and configure Azurite emulator");
//OpenFileFromAzureStorage.RunAsync("test.pdf").GetAwaiter().GetResult();
Console.WriteLine("ParsePdsObjects Sample");
ParsePdsObjects.Run(inputPath + "test.pdf");
Console.WriteLine("Read OCG Sample");
ReadOCGLayers.Run(inputPath + "test.pdf");
Console.WriteLine("Extract Text From OCG Layer Sample");
ExtractTextFromOCGLayer.Run(inputPath + "test.pdf");
Console.WriteLine("GetFormFieldValueEx Sample");
GetFormFieldValueEx.Run(inputPath + "test.pdf");
Console.WriteLine("Render Page sample");
RenderPage.Run(inputPath + "test.pdf", outputPath + "/RenderPage.jpg");
////////////////////////////////////////////////////////////////////////
//// Samples Basic version
////////////////////////////////////////////////////////////////////////
Console.WriteLine("AddComment Sample");
AddComment.Run(inputPath + "test.pdf", outputPath + "/AddComment.pdf");
Console.WriteLine("Add Attachment Annot Sample");
AddAttachmentAnnot.Run(inputPath + "test.pdf",
outputPath + "/AddAttachmentAnnot.pdf",
inputPath + "/AutoTag_Sample_original.pdf");
Console.WriteLine("Set Annot Appearance Sample");
SetAnnotAppearance.Run(inputPath + "test.pdf",
outputPath + "/SetAnnotAppearance.pdf",
inputPath + "/watermark.png");
Console.WriteLine("Set Annot Custom Appearance Sample");
SetAnnotCustomAppearance.Run(inputPath + "test.pdf",
outputPath + "/SetAnnotCustomAppearance.pdf",
inputPath + "/watermark.png");
Console.WriteLine("Extract PDF Data");
ExtractData.Run(inputPath + "test.pdf", "", false);
Console.WriteLine("AddTags Sample");
AddTags.Run(inputPath + "test.pdf",
outputPath + "/AddTags.pdf", configPath);
Console.WriteLine("Document Preflight Sample");
DocumentPreflight.Run(inputPath + "test.pdf", "");
Console.WriteLine("AddWatermark Sample");
AddWatermark.Run(inputPath + "test.pdf",
outputPath + "/AddWatermark.pdf",
inputPath + "/watermark.png",
0, -1, 1, false, PdfAlignment.kAlignmentLeft, PdfAlignment.kAlignmentTop, 0f, 70f, 1f, 45f, 0.9f
);
Console.WriteLine("ConvertToHtml Sample");
ConvertToHtml.Run(inputPath + "test.pdf",
outputPath + "/index.html",
configPath,
new PdfHtmlParams()
{
flags = Pdfix.kHtmlNoExternalCSS | Pdfix.kHtmlNoExternalJS | Pdfix.kHtmlNoExternalIMG | Pdfix.kHtmlNoExternalFONT
});
Console.WriteLine("ConvertToHtmlByPages Sample");
ConvertToHtmlByPages.Run(inputPath + "test.pdf",
configPath,
new PdfHtmlParams()
{
flags = Pdfix.kHtmlNoExternalCSS | Pdfix.kHtmlNoExternalJS | Pdfix.kHtmlNoExternalIMG | Pdfix.kHtmlNoExternalFONT
});
Console.WriteLine("DigitalSignature Sample");
DigitalSignature.Run(inputPath + "test.pdf",
outputPath + "/DigitalSignature.pdf",
inputPath + "/test.pfx", "TEST_PASSWORD");
Console.WriteLine("ExtractTables Sample");
ExtractTables.Run(inputPath + "test.pdf",
outputPath,
configPath);
Console.WriteLine("ExtractText Sample");
ExtractText.Run(inputPath + "test.pdf");
Console.WriteLine("ChangeTextColor Sample");
ChangeTextColor.Run(inputPath + "test.pdf",
outputPath + "/ChangeTextColor.pdf");
Console.WriteLine("ExportImages Sample");
ExportImages.Run(inputPath + "test.pdf",
outputPath);
Console.WriteLine("FlattenAnnots Sample");
FlattenAnnots.Run(inputPath + "test.pdf",
outputPath + "/FlattenAnnots.pdf");
Console.WriteLine("MakeAccessible Sample");
MakeAccessible.Run(inputPath + "test.pdf",
outputPath + "/MakeAccessible.pdf",
inputPath + "/make-accessible.json");
Console.WriteLine("TagsReadStructTree sample");
TagsReadStructTree.Run(inputPath + "test.pdf");
Console.WriteLine("TagEditImageAltText");
TagEditImageAltText.Run(inputPath + "test.pdf",
outputPath + "/TagEditImageAltText.pdf");
Console.WriteLine("TagEditStructureTree Sample");
TagEditStructureTree.Run(inputPath + "test.pdf",
outputPath + "/TagEditStructureTree.pdf");
Console.WriteLine("TagsReadingOrder sample");
TagsReadingOrder.Run(inputPath + "test.pdf",
outputPath + "/TagsReadingOrder.pdf");
Console.WriteLine("TagTableAsFigure sample");
TagTableAsFigure.Run(inputPath + "test.pdf",
outputPath + "/TagTableAsFigure.pdf");
Console.WriteLine("TagHeadings Sample");
TagHeadings.Run(inputPath + "test.pdf",
outputPath + "/TagHeadings.pdf");
Console.WriteLine("TagAsArtifact Sample");
TagAsArtifact.Run(inputPath + "test.pdf",
outputPath + "/TagAsArtifact.pdf");
Console.WriteLine("ThreadSafePdfix Sample");
ThreadSafePdfix.Run(inputPath + "test.pdf");
}
}
}