-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageConversion.js
54 lines (40 loc) · 1.52 KB
/
ImageConversion.js
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
import fs from 'fs';
import {
Pdf,
ImageResource,
align,
vAlign,
ImageInput
} from "@dynamicpdf/api"
export class ImageConversion {
static async Run() {
var pdf = new Pdf();
var imageResource = new ImageResource("c:/temp/dynamicpdf-api-samples/image-conversion/testimage.tif")
var imageResource2 = new ImageResource("c:/temp/dynamicpdf-api-samples/image-conversion/dynamicpdfLogo.png")
var imageInput = new ImageInput(imageResource);
var imageInput2 = new ImageInput(imageResource2);
imageInput.expandToFit = false;
imageInput.align = "center";
imageInput.vAlign = "center";
imageInput.pageHeight = 1008;
imageInput.pageWidth = 612;
imageInput2.expandToFit = true;
imageInput2.align = "center";
imageInput2.vAlign = "center";
imageInput2.pageHeight = 612;
imageInput2.pageWidth = 1008;
pdf.inputs.push(imageInput);
pdf.inputs.push(imageInput2);
pdf.apiKey = "DP.BKMFqqItEDZb9iBeSAJvzZAgqhH6oyY9SBiKezfyw+rTRosKxx0oD9f9";
var res = await pdf.process();
if (res.isSuccessful) {
var outFile = "C:/temp/dynamicpdf-api-samples/image-conversion/image-conversion-output.pdf";
var outStream = fs.createWriteStream(outFile);
outStream.write(res.content);
outStream.close();
} else {
console.log(res.errorJson);
}
}
}
await ImageConversion.Run();