SigningUtils.java
1.76 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.forms.option.LCFormsOptions
* com.adobe.forms.service.LCFormsService
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.addon.signing;
import com.adobe.forms.option.LCFormsOptions;
import com.adobe.forms.service.LCFormsService;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class SigningUtils {
private static final String PRINT_PDF_RENDER = "print.pdf";
private static final String OUTPUT_CONTENT_KEY = "outputContent";
private static final String FORM_PACKET_TYPE = "form";
protected static final Logger log = LoggerFactory.getLogger(SigningUtils.class);
private static byte[] getOutputContent(LCFormsService formsService, String formData, String templatePath, String renderType) {
LCFormsOptions lcFormsOptions = new LCFormsOptions();
lcFormsOptions.setTemplate(templatePath);
lcFormsOptions.setData(formData);
lcFormsOptions.setPacket("form");
lcFormsOptions.setRenderType(renderType);
lcFormsOptions.setUseXFA4J(null);
try {
Map renderMap = formsService.render(lcFormsOptions);
if (renderMap != null && renderMap.containsKey("outputContent")) {
return (byte[])renderMap.get("outputContent");
}
}
catch (Exception formsException) {
log.error("Error while generating the PDF for form data", (Throwable)formsException);
}
return null;
}
public static byte[] getPDFContent(LCFormsService formsService, String formData, String templatePath) {
return SigningUtils.getOutputContent(formsService, formData, templatePath, "print.pdf");
}
}