Hi All,
Greetings!
I am trying to assemble multiple fragments to create a one master xdp file so that I can use the same to generate the PDF.
I have tried the following documentation for the same;
Below is my code;
private Document assemblerService(SlingHttpServletRequest request)
{
log.info("--------------inside assemblerService method------------------");
ServiceClientFactory scf = scfProvider.getDefaultServiceClientFactory();
AssemblerServiceClient assemblerClient = new AssemblerServiceClient(scf);
StringBuffer ddxDoc = new StringBuffer();
ddxDoc.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
ddxDoc.append("<DDX xmlns=\"http://ns.adobe.com/DDX/1.0/\">");
ddxDoc.append("<XDP result=\"tuc018result.xdp\">");
ddxDoc.append("<XDP source=\"tuc018_template_flowed.xdp\">");
ddxDoc.append("<XDPContent insertionPoint=\"ddx_fragment\" source=\"frgTest.xdp\" fragment=\"frgTest\" required=\"false\"/>");
ddxDoc.append("</XDP></XDP></DDX>");
java.io.InputStream is = new java.io.ByteArrayInputStream(ddxDoc.toString().getBytes());
com.adobe.idp.Document myDDX = new com.adobe.idp.Document(is);
ResourceResolver resourceResolver = request.getResourceResolver();
String xdpDoc1 = "/content/dam/xdps/frgTest.xdp";
Resource res = resourceResolver.getResource(xdpDoc1);
Asset asset = res.adaptTo(Asset.class);
Resource original = asset.getOriginal();
InputStream xdpIS = original.adaptTo(InputStream.class);
com.adobe.idp.Document frgXdpDoc = new com.adobe.idp.Document(xdpIS);
//Create a Map object to store the PDF source documents
Map inputs = new HashMap();
//Place two entries into the Map object
inputs.put("frgTest",frgXdpDoc);
//Create an AssemblerOptionsSpec object
AssemblerOptionSpec assemblerSpec = new AssemblerOptionSpec();
assemblerSpec.setFailOnError(true);
//Submit the job to Assembler service
AssemblerResult jobResult = null;
try {
jobResult = assemblerClient.invokeDDX(myDDX,inputs,assemblerSpec);
}
catch (Exception e1) {
e1.printStackTrace();
}
java.util.Map allDocs = jobResult.getDocuments();
//Retrieve the resulting PDF document from the Map object
Document outDoc = null;
//Iterate through the map object to retrieve the resulting PDF document
for (Iterator i = allDocs.entrySet().iterator(); i.hasNext();)
{
// Retrieve the Map object's value
Map.Entry e = (Map.Entry)i.next();
Object o = e.getValue();
if (o instanceof Document) {
//Cast the Object to a Document
outDoc = (Document)o;
}
}
return outDoc;
}
Here in this code, I am using one xdp fragment to test if it can return a master xdp doc.
Please check and let me know if I am missing anything. Using this code I am getting following error;
14.01.2021 17:04:43.780 *ERROR* [0:0:0:0:0:0:0:1 [1610661875760] GET /bin/aem/api/generate/pdf/preview HTTP/1.1] com.aem.code.core.servlets.CreatePDF Error OCCURRED Exception: ALC-DSC-099-000: com.adobe.idp.dsc.DSCRuntimeException: java.net.ConnectException: Connection refused: connect
14.01.2021 17:04:43.781 *ERROR* [0:0:0:0:0:0:0:1 [1610661875760] GET /bin/aem/api/generate/pdf/preview HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught Throwable
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
I would suggest moving this thread to dedicated AEM Forms community to get a faster response
Hi,
I would suggest moving this thread to dedicated AEM Forms community to get a faster response
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies