11///usr/bin/env jbang "$0" "$@" ; exit $?
22//REPOS mavencentral,github=https://maven.pkg.github.com/4PointSolutions/*
3- //DEPS info.picocli:picocli:4.6.3
4- //DEPS com._4point.aem:fluentforms.core:0.0.3-SNAPSHOT com._4point.aem.docservices:rest-services.client:0.0.3-SNAPSHOT
5- //JAVA 11+
3+ //DEPS info.picocli:picocli:4.7.7
4+ //DEPS com._4point.aem:fluentforms.core:0.0.5-SNAPSHOT com._4point.aem.docservices:rest-services.client:0.0.5-SNAPSHOT
5+ //DEPS com._4point.aem.docservices.rest-services:rest-services.jersey-client:0.0.5-SNAPSHOT
6+ //JAVA 25+
67
78/*
9+ * This script demonstrates how to use FluentForms to invoke AEM Forms OutputService to render a non-interactive PDF form from
10+ * an XDP that resides on the AEM server. It can optionally use a local XML data file to populate the form with data.
11+ *
12+ * For example, to invoke this script against an AEM instance configured for the project's integration tests:
13+ * jbang invoke_output.java -f /opt/adobe/ff_it_files/SampleForm.xdp -o result_output.pdf
14+ *
815 * This script uses the 4PointSolutions/FluentFormsAPI GitHub package repository. GitHub requires a user to authenticate in order
916 * to access a package repository. In order for this script to work, you need to have your personal credentials configured
1017 * in your local settings.xml file (found in you $HOME/.m2 directory).
2734import java .nio .file .StandardCopyOption ;
2835import java .util .concurrent .Callable ;
2936
37+ import com ._4point .aem .docservices .rest_services .client .jersey .JerseyRestClient ;
3038import com ._4point .aem .docservices .rest_services .client .output .RestServicesOutputServiceAdapter ;
3139import com ._4point .aem .fluentforms .api .Document ;
40+ import com ._4point .aem .fluentforms .api .PathOrUrl ;
3241import com ._4point .aem .fluentforms .impl .SimpleDocumentFactoryImpl ;
3342import com ._4point .aem .fluentforms .impl .UsageContext ;
3443import com ._4point .aem .fluentforms .impl .output .OutputServiceImpl ;
4352class invoke_aem implements Callable <Integer > {
4453
4554 @ Option (names = {"-f" , "--form" }, description = "A filepath to the XDP." , required = true )
46- private Path xdpLocation ;
55+ private String xdpLocation ;
4756
4857 @ Option (names = {"-d" , "--data" }, description = "A filepath to the XML data file. (Optional)" )
4958 private Path xmlLocation ;
@@ -59,9 +68,9 @@ public static void main(String... args) {
5968 @ Override
6069 public Integer call () throws Exception {
6170
62- var adapter = RestServicesOutputServiceAdapter .builder ()
63- .machineName ("172.18.110.35 " )
64- .port (4502 )
71+ var adapter = RestServicesOutputServiceAdapter .builder (JerseyRestClient . factory () )
72+ .machineName ("localhost " )
73+ .port (54740 )
6574 .basicAuthentication ("admin" , "admin" )
6675 .useSsl (false )
6776 .build ();
@@ -79,13 +88,10 @@ public Integer call() throws Exception {
7988// .setRetainUnsignedSignatureFields(true)
8089 .setTaggedPDF (true );
8190
82- if (Files .exists (xdpLocation )) {
83- builder = builder .setContentRoot (xdpLocation .toAbsolutePath ().getParent ());
84- }
85-
91+ PathOrUrl xdpPathOrUrl = PathOrUrl .from (xdpLocation );
8692 Document pdfResult = xmlLocation == null ?
87- builder .executeOn (xdpLocation . getFileName () ) :
88- builder .executeOn (xdpLocation . getFileName () , SimpleDocumentFactoryImpl .getFactory ().create (xmlLocation . toFile ( )));
93+ builder .executeOn (xdpPathOrUrl ) :
94+ builder .executeOn (xdpPathOrUrl , SimpleDocumentFactoryImpl .getFactory ().create (Files . readAllBytes ( xmlLocation )));
8995
9096 System .out .println ("Writing output to " + outLocation );
9197 Files .copy (pdfResult .getInputStream (), outLocation , StandardCopyOption .REPLACE_EXISTING );
0 commit comments