-
Notifications
You must be signed in to change notification settings - Fork 0
/
OutlinesSolution.cs
62 lines (41 loc) · 1.48 KB
/
OutlinesSolution.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
using DynamicPDF.Api;
using DynamicPDF.Api.Elements;
using System;
using System.IO;
namespace DynamicPdfClientLibraryExamples.Examples.Solutions
{
class OutlinesSolution
{
public static void Run(string apiKey, string basePath, string outputPath)
{
Pdf pdf = new Pdf();
pdf.ApiKey = apiKey;
PageInput pageInput = pdf.AddPage();
TextElement element = new TextElement("Hello World 1", ElementPlacement.TopCenter);
pageInput.Elements.Add(element);
PageInput pageInput1 = pdf.AddPage();
TextElement element1 = new TextElement("Hello World 2", ElementPlacement.TopCenter);
pageInput1.Elements.Add(element1);
PageInput pageInput2 = pdf.AddPage();
TextElement element2 = new TextElement("Hello World 3", ElementPlacement.TopCenter);
pageInput2.Elements.Add(element2);
var inputA = pdf.AddPdf(new PdfResource(basePath + "PdfOutlineInput.pdf"));
inputA.Id = "pdfoutlineinput";
Outline rootOutline = pdf.Outlines.Add("Root Outline");
rootOutline.Children.Add("Page 1", pageInput);
rootOutline.Children.Add("Page 2", pageInput1);
rootOutline.Children.Add("Page 3", pageInput2);
rootOutline.Children.AddPdfOutlines(inputA);
Console.WriteLine(pdf.GetInstructionsJson(true));
PdfResponse pdfResponse = pdf.Process();
if (pdfResponse.IsSuccessful)
{
File.WriteAllBytes(outputPath + "/outlines-output.pdf", pdfResponse.Content);
}
else
{
Console.WriteLine(pdfResponse.ErrorJson);
}
}
}
}