Vesatility of the script QPac


i writing servlet call render qpac had difficulty passing data keep getting error "content no allowed in prolog". data passing valid xml realised limitation of qpac. have wrote xml data file disk passed path isn't great solution.

i discovered duplicate functionality of render qpac (with more versatility). can pass in process variables servlet
add following code script qpac:

import com.adobe.fm.fmconstants;
import com.adobe.formserver.client.ejbclient;
import com.adobe.formserver.interfaces.iformserver;
import com.adobe.formserver.interfaces.ioutputcontext;
import com.adobe.formserver.interfaces.renderformexception;
import com.adobe.idp.context;
import com.adobe.idp.um.api.authenticationmanager;
import com.adobe.idp.um.api.umexception;
import com.adobe.idp.um.api.umfactory;
import com.adobe.idp.um.api.umconstants;
import com.adobe.idp.um.api.infomodel.authresult;
import com.adobe.idp.document;

import com.adobe.workflow.pat.service.patabstractservice;
import com.adobe.workflow.pat.service.patexecutioncontext;
import com.adobe.workflow.pat.service.patserviceexception;
import com.adobe.workflow.pat.service.patserviceresult;

import com.adobe.workflow.pat.service.patservicecontext;

context context = null;
ioutputcontext ioutputcontext=null;
string formtemplate="";
string formpref="";
document data=null;
string options="";
string useragent="";
string webroot="";
string targeturl="";
string contenturi="";
string baseurl="";
com.adobe.idp.document outdoc=null;

try {
authenticationmanager manager = umfactory.getinstance().getauthenticationmanager();
context context = new context();
authresult result = manager.getauthresultonbehalfofuser(
"livecycle form manager system user",
umconstants.specialdefaultprincipals.domain_default,
new context());
context.initprincipal(result);

iformserver ofs = new ejbclient();

if(ofs!=null){
ofs.setinvocationcontext(context);
}

formtemplate = patexeccontext.getprocessdatastringvalue("/process_data/@templatepath");
formpref = patexeccontext.getprocessdatastringvalue("/process_data/@formpref");
data = (document)patexeccontext.getprocessdatavalue("/process_data/@data");
options = patexeccontext.getprocessdatastringvalue("/process_data/@options");
targeturl = patexeccontext.getprocessdatastringvalue("/process_data/@targeturl");
contenturi = patexeccontext.getprocessdatastringvalue("/process_data/@contenturi");
baseurl = patexeccontext.getprocessdatastringvalue("/process_data/@baseurl");

ioutputcontext = ofs.renderform(formtemplate, //template name
formpref, //render preference
data, options, useragent, webroot, //app url
targeturl, contenturi, //contentroot uri
baseurl);



outdoc = new com.adobe.idp.document(ioutputcontext.getoutputcontent());
outdoc.setcontenttype(ioutputcontext.getcontenttype());

patexeccontext.setprocessdatavalue("/process_data/@output",outdoc);


} catch (umexception e) {
// todo auto-generated catch block
e.printstacktrace();
}
catch (renderformexception e) {
// todo auto-generated catch block
e.printstacktrace();
}

very cool - indeed show versatility of script qpac.

for readers of post please note script qpac default "interactive" qpac - meaning if use in workflow intend results sycnronousinvoke() not return results immediately.  in order resulting pdf must call getresults().

this can tweaked deploying scriptqpac not interactive qpac.  must modify component.xml file in script qpac false , repackage jar file.  once deploy workflow notice can use qpac in syncronous workflow calls, , results returned. 

note:  once make change not use "interactive" checkbox in script qpac.

good luck!

will


More discussions in LiveCycle pre-ES (6.x and 7.x) discussions


adobe

Comments