SigningUtils.java 1.76 KB
/*
 * 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");
    }
}