Quantcast
Viewing all articles
Browse latest Browse all 85594

FileAttachments in Execute Script

How to add attachments to generated PDF document (i.e. MainForm) and send it to a mail in a ALC process?

 

Here, my script below

 

import java.util.Map;

import java.util.HashMap;

import java.lang.String;

import java.lang.StringBuilder;

import java.util.List;

import com.adobe.idp.Document;

 

 

String QUOTE = "\"";

 

 

quote( String s ) {

  return  QUOTE + s + QUOTE;

}

 

 

generateDDX() {

 

 

List attachList = patExecContext.getProcessDataListValue("/process_data/attachments1");

 

Document parentDocument = patExecContext.getProcessDataDocumentValue("/process_data/formDoc");

String documentName = parentDocument.getAttribute("basename");

 

 

final StringBuilder ddx = new StringBuilder();

final String newLine = "\n";

 

 

ddx.append( "<?xml version=" ).append( quote("1.0" ) ).append( " encoding=" ) .append( quote( "UTF-8") ).append(  "?>"  ).append( newLine );

ddx.append( "<DDX xmlns=" ).append( this.quote( "http://ns.adobe.com/DDX/1.0/" ) ).append( ">" ).append( newLine );

ddx.append( "<PDF result=" ).append( this.quote( "out.pdf" )).append( ">" ).append( newLine );

ddx.append( "<PDF source=" ).append( this.quote( "in.pdf" )  ).append(">").append( newLine );

ddx.append( "<NoForms/>" ).append( newLine );

ddx.append( "<NoXFA/>" ).append( newLine );

 

Map documents = new HashMap();

for (int i=0; i<attachList.size(); i++) {

 

Document document = (Document)attachList.get(i);

String currentFileName = document.getAttribute("basename");

 

ddx.append( "<FileAttachments source=" ).append( this.quote( currentFileName ) ).append(  ">" ).append( newLine );

ddx.append( "<File filename=" ).append( this.quote( currentFileName )  ).append(  "/>" ).append( newLine );

ddx.append( "<FilenameEncoding encoding=" ) .append( this.quote( "UTF-8" )  ).append(  "/>" ).append( newLine );

ddx.append( "</FileAttachments>").append( newLine );

 

documents.put(currentFileName, document);

}

 

patExecContext.setProcessDataMapValue("/process_data/documents", documents);

ddx.append( "</PDF>\n</PDF>\n</DDX>\n" );

patExecContext.setProcessDataStringValue( "/process_data/@AssemblerDDX", ddx.toString() );

}

 

this.generateDDX();


Viewing all articles
Browse latest Browse all 85594

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>