Quantcast
Channel: Adobe Community: Message List - Including attachments from PDF in Save as Draft and Submit as XDP
Viewing all articles
Browse latest Browse all 4

Re: Including attachments from PDF in Save as Draft and Submit as XDP

$
0
0

Revised Execute script. Server was running out of heap space with large attachments. Creating the Document objects as temp files instead of in memory solves that. I also added the part that wipes the Base64 Attachments out of the XML.

        int count = 0;        Map attachmentMap = new HashMap();        String name="";        String b64Data="";        File tempFile=null;        FileOutputStream outStream=null;        Document attDoc=null;        int i=0;        Node ndAttach = (Node) patExecContext.getProcessDataValue("/process_data/xmlData/Formdata/FileAttachments");        NodeList children;        Node childNode = null;        if (ndAttach != null) {            children = ndAttach.getChildNodes();            if (children != null) {                childNode = children.item(i);                if (childNode instanceof Element) {                    System.out.println("tag name: " + ((Element)childNode).getTagName());                }                count = children.getLength();            }        }        for (i = 1; i <= count; i++){            b64Data = patExecContext.getProcessDataStringValue("/process_data/xmlData/Formdata/FileAttachments/FileAttachment[" + i + "]/Base64Data");            if (b64Data != null && b64Data.length() != 0) {                name = patExecContext.getProcessDataStringValue("/process_data/xmlData/Formdata/FileAttachments/FileAttachment[" + i + "]/FileName");                tempFile = File.createTempFile("Attachment", ".tmp");                outStream = new FileOutputStream(tempFile);                outStream.write(Base64.decodeBase64(b64Data.getBytes()));                outStream.close();                attDoc = new Document(tempFile, true);                attDoc.setAttribute("basename", name);                attDoc.setAttribute("description", patExecContext.getProcessDataStringValue("/process_data/xmlData/Formdata/FileAttachments/FileAttachment[" + i + "]/FileDesc"));                attDoc.setAttribute("wsPermission", "1");                attachmentMap.put(name, attDoc);            }        }        patExecContext.setProcessDataMapValue("/process_data/mapAttachments", attachmentMap);        while (ndAttach.hasChildNodes()) {            ndAttach.removeChild(ndAttach.getLastChild());        }

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images