-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathInitialization.cs
52 lines (47 loc) · 1.96 KB
/
Initialization.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
////////////////////////////////////////////////////////////////////////////////////////////////////
// Initialization.cs
// Copyright (c) 2018 PDFix. All Rights Reserved.
////////////////////////////////////////////////////////////////////////////////////////////////////
using System;
using PDFixSDK.Pdfix;
namespace PDFix.App.Module
{
class Initialization
{
public static void Run(
String email, // authorization email
String licenseKey // license key
)
{
Pdfix pdfix = new Pdfix();
if (pdfix == null)
throw new Exception("Pdfix initialization fail. Please set correct email and license key.");
Console.WriteLine("PDFix SDK version: " +
pdfix.GetVersionMajor().ToString() + "." +
pdfix.GetVersionMinor().ToString() + "." +
pdfix.GetVersionPatch().ToString());
if (licenseKey.Length > 0)
{
if (email.Length > 0)
{
// Authorization using an account name/key
var account_auth = pdfix.GetAccountAuthorization();
if (account_auth.Authorize(email, licenseKey) == false)
{
throw new Exception("PDFix SDK Account Authorization failed");
}
}
else
{
// Authorization using the activation key
var standard_auth = pdfix.GetStandardAuthorization();
if (!standard_auth.IsAuthorized() && !standard_auth.Activate(licenseKey))
{
throw new Exception("PDFix SDK Standard Authorization failed");
}
}
}
pdfix.Destroy();
}
}
}