-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApi2PdfController.cls
More file actions
84 lines (68 loc) · 3.05 KB
/
Copy pathApi2PdfController.cls
File metadata and controls
84 lines (68 loc) · 3.05 KB
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
public with sharing class Api2PdfController {
private Api2PdfClient a2pClient = null;
public String PdfUrl {get;set;}
public Api2PdfResponse PdfResponse {get;set;}
public string ApiKeyForTest{get;set;}
public Api2PdfController (){
Api2PdfConfig__c setting = Api2PdfConfig__c.getOrgDefaults();
a2pClient = new Api2PdfClient(setting.Api_Key__c);
}
public Api2PdfController (string apiKey){
a2pClient = new Api2PdfClient(apiKey);
}
public void wkhtmlToPdfFromHtml(){
PdfResponse = a2pClient.wkhtmlToPdfFromHtml('<p>test</p>', true, 'test.pdf');
PdfUrl= PdfResponse.getPdf();
}
public void wkhtmlToPdfFromHtmlWithOptions(){
Map<String, String> options = new Map<String, String>();
options.put('orientation', 'landscape');
options.put('pageSize', 'A4');
PdfResponse = a2pClient.wkhtmlToPdfFromHtml('<p>test</p>', true, 'test.pdf', options);
PdfUrl= PdfResponse.getPdf();
}
public void wkhtmlToPdfFromUrl(){
PdfResponse = a2pClient.wkhtmlToPdfFromUrl('https://www.google.com', true, 'test.pdf');
PdfUrl= pdfResponse.getPdf();
}
public void wkhtmlToPdfFromUrlWithOptions(){
Map<String, String> options = new Map<String, String>();
options.put('orientation', 'landscape');
options.put('pageSize', 'A4');
PdfResponse = a2pClient.wkhtmlToPdfFromUrl('https://www.google.com', true, 'test.pdf', options);
PdfUrl= PdfResponse.getPdf();
}
public void headlessChromeFromHtml(){
PdfResponse = a2pClient.headlessChromeFromHtml('<p>test</p>', true, 'test.pdf');
PdfUrl= PdfResponse.getPdf();
}
public void headlessChromeFromHtmlWithOptions(){
Map<String, String> options = new Map<String, String>();
options.put('orientation', 'landscape');
options.put('pageSize', 'A4');
PdfResponse = a2pClient.headlessChromeFromHtml('<p>test</p>', true, 'test.pdf', options);
PdfUrl= PdfResponse.getPdf();
}
public void headlessChromeFromUrl(){
PdfResponse = a2pClient.headlessChromeFromUrl('https://www.google.com', true, 'test.pdf');
PdfUrl= pdfResponse.getPdf();
}
public void headlessChromeFromUrlOptions(){
Map<String, String> options = new Map<String, String>();
options.put('orientation', 'landscape');
options.put('pageSize', 'A4');
PdfResponse = a2pClient.headlessChromeFromUrl('https://www.google.com', true, 'test.pdf', options);
PdfUrl= PdfResponse.getPdf();
}
public void libreofficeConvert(){
PdfResponse = a2pClient.libreofficeConvert('http://homepages.inf.ed.ac.uk/neilb/TestWordDoc.doc', true, 'test.pdf');
PdfUrl= PdfResponse.getPdf();
}
public void mergePdf(){
String[] urls = new List<String>();
urls.add('http://www.orimi.com/pdf-test.pdf');
urls.add('http://www.orimi.com/pdf-test.pdf');
PdfResponse = a2pClient.mergePdf(urls, true, 'test.pdf');
PdfUrl= PdfResponse.getPdf();
}
}