-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageConversion.cs
52 lines (42 loc) · 1.58 KB
/
ImageConversion.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
using DynamicPDF.Api;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DynamicPdfClientLibraryExamples.Examples.Solutions
{
class ImageConversion
{
public static void Run(string apiKey, string basePath, string outputPath)
{
Pdf pdf = new Pdf();
pdf.ApiKey = apiKey;
ImageResource imageResource = new ImageResource(basePath + "testimage.tif");
ImageInput imageInput = pdf.AddImage(imageResource);
imageInput.Align = Align.Center;
imageInput.VAlign = VAlign.Center;
imageInput.ExpandToFit = false;
imageInput.PageHeight = 1008;
imageInput.PageWidth = 612;
ImageResource imageResourceTwo = new ImageResource(basePath + "dynamicpdfLogo.png");
ImageInput imageInputTwo = pdf.AddImage(imageResourceTwo);
imageInputTwo.Align = Align.Center;
imageInputTwo.VAlign = VAlign.Center;
imageInputTwo.ExpandToFit = true;
imageInputTwo.PageHeight = 612;
imageInputTwo.PageWidth = 1008;
Console.WriteLine(pdf.GetInstructionsJson(true));
PdfResponse pdfResponse = pdf.Process();
if (pdfResponse.IsSuccessful)
{
File.WriteAllBytes(outputPath + "/convert-img-to-pdf-output.pdf", pdfResponse.Content);
}
else
{
Console.WriteLine(pdfResponse.ErrorJson);
}
}
}
}