|
| 1 | +///usr/bin/env jbang "$0" "$@" ; exit $? |
| 2 | +//REPOS mavencentral,github=https://maven.pkg.github.com/4PointSolutions/* |
| 3 | +//DEPS com._4point.aem:fluentforms.core:0.0.3-SNAPSHOT com._4point.aem.docservices:rest-services.client:0.0.3-SNAPSHOT |
| 4 | +//JAVA 21+ |
| 5 | + |
| 6 | +/* |
| 7 | + * This script uses the 4PointSolutions/FluentFormsAPI GitHub package repository. GitHub requires a user to authenticate in order |
| 8 | + * to access a package repository. In order for this script to work, you need to have your personal credentials configured |
| 9 | + * in your local settings.xml file (found in you $HOME/.m2 directory). |
| 10 | + * |
| 11 | + * Your settings.xml should look something like this: |
| 12 | + * <?xml version="1.0"?> |
| 13 | + * <settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/SETTINGS/1.0.0"> |
| 14 | + * <servers> |
| 15 | + * <server> |
| 16 | + * <id>github</id> |
| 17 | + * <username>Your GitHub Username goes here</username> |
| 18 | + * <password>Your Personal Access Token goes here</password> |
| 19 | + * </server> |
| 20 | + * </servers> |
| 21 | + * </settings> |
| 22 | + * |
| 23 | + */ |
| 24 | +import java.awt.Desktop; |
| 25 | +import java.awt.GraphicsEnvironment; |
| 26 | +import java.nio.file.Files; |
| 27 | +import java.nio.file.Path; |
| 28 | +import java.nio.file.StandardCopyOption; |
| 29 | + |
| 30 | +import com._4point.aem.docservices.rest_services.client.forms.RestServicesFormsServiceAdapter; |
| 31 | +import com._4point.aem.fluentforms.api.Document; |
| 32 | +import com._4point.aem.fluentforms.impl.UsageContext; |
| 33 | +import com._4point.aem.fluentforms.impl.forms.FormsServiceImpl; |
| 34 | +import com.adobe.fd.forms.api.AcrobatVersion; |
| 35 | + |
| 36 | +class SmokeTest { |
| 37 | + |
| 38 | + public static void main(String... args) { |
| 39 | + |
| 40 | + try { |
| 41 | + Path outLocation = Files.createTempFile("AemForms_SmokeTest", ".pdf"); |
| 42 | + |
| 43 | + // If AEM is not localhost:4502 or does not use default credentials, change the values below. |
| 44 | + var adapter = RestServicesFormsServiceAdapter.builder() |
| 45 | + .machineName("localhost") |
| 46 | + .port(4502) |
| 47 | + .basicAuthentication("admin", "admin") |
| 48 | + .useSsl(false) |
| 49 | + .build(); |
| 50 | + |
| 51 | + var underTest = new FormsServiceImpl(adapter, UsageContext.CLIENT_SIDE); |
| 52 | + |
| 53 | + |
| 54 | + var builder = underTest.renderPDFForm() |
| 55 | + .setAcrobatVersion(AcrobatVersion.Acrobat_10_1) |
| 56 | + .setEmbedFonts(true) |
| 57 | + // Less used parameters are commented out which leaves them at default. |
| 58 | +// .setLinearizedPDF(true) |
| 59 | +// .setLocale(Locale.CANADA_FRENCH) |
| 60 | +// .setRetainPDFFormState(true) |
| 61 | +// .setRetainUnsignedSignatureFields(true) |
| 62 | + .setTaggedPDF(true); |
| 63 | + |
| 64 | + Document pdfResult = builder.executeOn(SMOKE_TEST_FORM.getBytes(), SMOKE_TEST_DATA.getBytes()); |
| 65 | + |
| 66 | + System.out.println("✅ SmokeTest passed - writing output to " + outLocation.toAbsolutePath()); |
| 67 | + Files.copy(pdfResult.getInputStream(), outLocation, StandardCopyOption.REPLACE_EXISTING); |
| 68 | + |
| 69 | + if (!GraphicsEnvironment.isHeadless()) { |
| 70 | + Desktop desktop = Desktop.getDesktop(); |
| 71 | + try { |
| 72 | + desktop.browse(outLocation.toAbsolutePath().toUri()); |
| 73 | + } catch (UnsupportedOperationException e) { |
| 74 | + System.out.println("Bypassed Desktop Launch"); |
| 75 | + } |
| 76 | + } else { |
| 77 | + System.out.println("Bypassing Desktop Launch"); |
| 78 | + } |
| 79 | + |
| 80 | + System.exit(0); |
| 81 | + } catch (Exception e) { |
| 82 | + e.printStackTrace(); |
| 83 | + System.out.println("� SmokeTest failed"); |
| 84 | + System.exit(-1); |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + private static final String SMOKE_TEST_DATA = |
| 89 | + """ |
| 90 | + <?xml version="1.0" encoding="UTF-8"?> |
| 91 | + <form1> |
| 92 | + <SampleField>This is sample data that demonstrates that data was merged with the form.</SampleField> |
| 93 | + </form1> |
| 94 | + """; |
| 95 | + |
| 96 | + private static final String SMOKE_TEST_FORM = |
| 97 | + """ |
| 98 | + <?xml version="1.0" encoding="UTF-8"?> |
| 99 | + <?xfa generator="Designer_V6.5.19.20231117.1.148" APIVersion="3.6.23313.0"?> |
| 100 | + <xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2024-09-16T13:50:19Z" uuid="79b538a1-6192-490d-b164-4afa39964215"> |
| 101 | + <template xmlns="http://www.xfa.org/schema/xfa-template/3.6/"> |
| 102 | + <?formServer defaultPDFRenderFormat acrobat11.0dynamic?> |
| 103 | + <?formServer allowRenderCaching 0?> |
| 104 | + <?formServer formModel both?> |
| 105 | + <subform name="form1" layout="tb" locale="en_CA" restoreState="auto"> |
| 106 | + <pageSet> |
| 107 | + <pageArea name="Page1" id="Page1"> |
| 108 | + <contentArea x="0.25in" y="0.25in" w="576pt" h="756pt"/> |
| 109 | + <medium stock="default" short="612pt" long="792pt"/> |
| 110 | + <?templateDesigner expand 1?></pageArea> |
| 111 | + <?templateDesigner expand 1?></pageSet> |
| 112 | + <subform w="576pt" h="756pt"> |
| 113 | + <draw name="Text1" y="6.35mm" x="6.35mm" w="193.675mm" h="19.05mm"> |
| 114 | + <ui> |
| 115 | + <textEdit/> |
| 116 | + </ui> |
| 117 | + <value> |
| 118 | + <exData contentType="text/html"> |
| 119 | + <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p style="text-align:center;text-decoration:none;letter-spacing:0in">Sample Form</p></body> |
| 120 | + </exData> |
| 121 | + </value> |
| 122 | + <font size="48pt" typeface="Myriad Pro" baselineShift="0pt"/> |
| 123 | + <margin topInset="0.5mm" bottomInset="0.5mm" leftInset="0.5mm" rightInset="0.5mm"/> |
| 124 | + <para spaceAbove="0pt" spaceBelow="0pt" textIndent="0pt" marginLeft="0pt" marginRight="0pt"/> |
| 125 | + </draw> |
| 126 | + <field name="SampleField" y="34.925mm" x="6.35mm" w="193.675mm" h="9mm"> |
| 127 | + <ui> |
| 128 | + <textEdit> |
| 129 | + <border> |
| 130 | + <edge/> |
| 131 | + </border> |
| 132 | + <margin/> |
| 133 | + </textEdit> |
| 134 | + </ui> |
| 135 | + <font typeface="Myriad Pro"/> |
| 136 | + <margin topInset="1mm" bottomInset="1mm" leftInset="1mm" rightInset="1mm"/> |
| 137 | + <para vAlign="middle"/> |
| 138 | + <caption reserve="25mm"> |
| 139 | + <para vAlign="middle"/> |
| 140 | + <value> |
| 141 | + <text>Sample Field</text> |
| 142 | + </value> |
| 143 | + </caption> |
| 144 | + </field> |
| 145 | + <?templateDesigner expand 1?></subform> |
| 146 | + <proto/> |
| 147 | + <desc> |
| 148 | + <text name="version">6.5.19.20231117.148</text> |
| 149 | + <text name="contact">support@4point.com</text> |
| 150 | + <text name="description">This form is used for performing a Smoke Test of an AEM instance. It exercises the Document Services APIs.</text> |
| 151 | + <text name="creator">4Point Solutions</text> |
| 152 | + <text name="title">Smoke Test</text> |
| 153 | + </desc> |
| 154 | + <?templateDesigner expand 1?> |
| 155 | + <?templateDesigner Hyphenation excludeInitialCap:1, excludeAllCaps:1, wordCharCnt:7, remainCharCnt:3, pushCharCnt:3?> |
| 156 | + <?renderCache.subset "Myriad Pro" 0 0 ISO-8859-1 4 60 15 0001002700340035004200450046004A004D004E00500051005300550059 FSTadeilmoprtx?></subform> |
| 157 | + <?templateDesigner DefaultPreviewDynamic 1?> |
| 158 | + <?templateDesigner Grid show:1, snap:1, units:0, color:ff8080, origin:(0,0), interval:(125000,125000)?> |
| 159 | + <?templateDesigner Zoom 106?> |
| 160 | + <?templateDesigner WidowOrphanControl 0?> |
| 161 | + <?templateDesigner SavePDFWithLog 0?> |
| 162 | + <?templateDesigner FormTargetVersion 36?> |
| 163 | + <?templateDesigner DefaultLanguage JavaScript?> |
| 164 | + <?templateDesigner DefaultRunAt server?> |
| 165 | + <?acrobat JavaScript strictScoping?> |
| 166 | + <?PDFPrintOptions embedViewerPrefs 0?> |
| 167 | + <?PDFPrintOptions embedPrintOnFormOpen 0?> |
| 168 | + <?PDFPrintOptions scalingPrefs 0?> |
| 169 | + <?PDFPrintOptions enforceScalingPrefs 0?> |
| 170 | + <?PDFPrintOptions paperSource 0?> |
| 171 | + <?PDFPrintOptions duplexMode 0?> |
| 172 | + <?templateDesigner DefaultPreviewType print?> |
| 173 | + <?templateDesigner DefaultPreviewPagination simplex?> |
| 174 | + <?templateDesigner XDPPreviewFormat 19?> |
| 175 | + <?templateDesigner DefaultPreviewDataFileName .\\\\SmokeTestData.xml?> |
| 176 | + <?templateDesigner DefaultCaptionFontSettings face:Myriad Pro;size:10;weight:normal;style:normal?> |
| 177 | + <?templateDesigner DefaultValueFontSettings face:Myriad Pro;size:10;weight:normal;style:normal?> |
| 178 | + <?templateDesigner SaveTaggedPDF 0?> |
| 179 | + <?templateDesigner SavePDFWithEmbeddedFonts 0?> |
| 180 | + <?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?></template> |
| 181 | + <config xmlns="http://www.xfa.org/schema/xci/3.0/"> |
| 182 | + <agent name="designer"> |
| 183 | + <!-- [0..n] --> |
| 184 | + <destination>pdf</destination> |
| 185 | + <pdf> |
| 186 | + <!-- [0..n] --> |
| 187 | + <fontInfo/> |
| 188 | + </pdf> |
| 189 | + </agent> |
| 190 | + <present> |
| 191 | + <!-- [0..n] --> |
| 192 | + <pdf> |
| 193 | + <!-- [0..n] --> |
| 194 | + <fontInfo> |
| 195 | + <embed>0</embed> |
| 196 | + </fontInfo> |
| 197 | + <tagged>0</tagged> |
| 198 | + <version>1.7</version> |
| 199 | + <adobeExtensionLevel>11</adobeExtensionLevel> |
| 200 | + </pdf> |
| 201 | + <xdp> |
| 202 | + <packets>*</packets> |
| 203 | + </xdp> |
| 204 | + </present> |
| 205 | + </config> |
| 206 | + <localeSet xmlns="http://www.xfa.org/schema/xfa-locale-set/2.7/"> |
| 207 | + <locale name="en_CA" desc="English (Canada)"> |
| 208 | + <calendarSymbols name="gregorian"> |
| 209 | + <monthNames> |
| 210 | + <month>January</month> |
| 211 | + <month>February</month> |
| 212 | + <month>March</month> |
| 213 | + <month>April</month> |
| 214 | + <month>May</month> |
| 215 | + <month>June</month> |
| 216 | + <month>July</month> |
| 217 | + <month>August</month> |
| 218 | + <month>September</month> |
| 219 | + <month>October</month> |
| 220 | + <month>November</month> |
| 221 | + <month>December</month> |
| 222 | + </monthNames> |
| 223 | + <monthNames abbr="1"> |
| 224 | + <month>Jan</month> |
| 225 | + <month>Feb</month> |
| 226 | + <month>Mar</month> |
| 227 | + <month>Apr</month> |
| 228 | + <month>May</month> |
| 229 | + <month>Jun</month> |
| 230 | + <month>Jul</month> |
| 231 | + <month>Aug</month> |
| 232 | + <month>Sep</month> |
| 233 | + <month>Oct</month> |
| 234 | + <month>Nov</month> |
| 235 | + <month>Dec</month> |
| 236 | + </monthNames> |
| 237 | + <dayNames> |
| 238 | + <day>Sunday</day> |
| 239 | + <day>Monday</day> |
| 240 | + <day>Tuesday</day> |
| 241 | + <day>Wednesday</day> |
| 242 | + <day>Thursday</day> |
| 243 | + <day>Friday</day> |
| 244 | + <day>Saturday</day> |
| 245 | + </dayNames> |
| 246 | + <dayNames abbr="1"> |
| 247 | + <day>Sun</day> |
| 248 | + <day>Mon</day> |
| 249 | + <day>Tue</day> |
| 250 | + <day>Wed</day> |
| 251 | + <day>Thu</day> |
| 252 | + <day>Fri</day> |
| 253 | + <day>Sat</day> |
| 254 | + </dayNames> |
| 255 | + <meridiemNames> |
| 256 | + <meridiem>AM</meridiem> |
| 257 | + <meridiem>PM</meridiem> |
| 258 | + </meridiemNames> |
| 259 | + <eraNames> |
| 260 | + <era>BC</era> |
| 261 | + <era>AD</era> |
| 262 | + </eraNames> |
| 263 | + </calendarSymbols> |
| 264 | + <datePatterns> |
| 265 | + <datePattern name="full">EEEE, MMMM D, YYYY</datePattern> |
| 266 | + <datePattern name="long">MMMM D, YYYY</datePattern> |
| 267 | + <datePattern name="med">D-MMM-YY</datePattern> |
| 268 | + <datePattern name="short">DD/MM/YY</datePattern> |
| 269 | + </datePatterns> |
| 270 | + <timePatterns> |
| 271 | + <timePattern name="full">h:MM:SS A Z</timePattern> |
| 272 | + <timePattern name="long">h:MM:SS A Z</timePattern> |
| 273 | + <timePattern name="med">h:MM:SS A</timePattern> |
| 274 | + <timePattern name="short">h:MM A</timePattern> |
| 275 | + </timePatterns> |
| 276 | + <dateTimeSymbols>GyMdkHmsSEDFwWahKzZ</dateTimeSymbols> |
| 277 | + <numberPatterns> |
| 278 | + <numberPattern name="numeric">z,zz9.zzz</numberPattern> |
| 279 | + <numberPattern name="currency">$z,zz9.99</numberPattern> |
| 280 | + <numberPattern name="percent">z,zz9%</numberPattern> |
| 281 | + </numberPatterns> |
| 282 | + <numberSymbols> |
| 283 | + <numberSymbol name="decimal">.</numberSymbol> |
| 284 | + <numberSymbol name="grouping">,</numberSymbol> |
| 285 | + <numberSymbol name="percent">%</numberSymbol> |
| 286 | + <numberSymbol name="minus">-</numberSymbol> |
| 287 | + <numberSymbol name="zero">0</numberSymbol> |
| 288 | + </numberSymbols> |
| 289 | + <currencySymbols> |
| 290 | + <currencySymbol name="symbol">$</currencySymbol> |
| 291 | + <currencySymbol name="isoname">CAD</currencySymbol> |
| 292 | + <currencySymbol name="decimal">.</currencySymbol> |
| 293 | + </currencySymbols> |
| 294 | + <typefaces> |
| 295 | + <typeface name="Myriad Pro"/> |
| 296 | + <typeface name="Minion Pro"/> |
| 297 | + <typeface name="Courier Std"/> |
| 298 | + <typeface name="Adobe Pi Std"/> |
| 299 | + <typeface name="Adobe Hebrew"/> |
| 300 | + <typeface name="Adobe Arabic"/> |
| 301 | + <typeface name="Adobe Thai"/> |
| 302 | + <typeface name="Kozuka Gothic Pro-VI M"/> |
| 303 | + <typeface name="Kozuka Mincho Pro-VI R"/> |
| 304 | + <typeface name="Adobe Ming Std L"/> |
| 305 | + <typeface name="Adobe Song Std L"/> |
| 306 | + <typeface name="Adobe Myungjo Std M"/> |
| 307 | + <typeface name="Adobe Devanagari"/> |
| 308 | + </typefaces> |
| 309 | + </locale> |
| 310 | + </localeSet> |
| 311 | + <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 9.0-c000 79.cca54b0, 2022/11/26-09:29:55 "> |
| 312 | + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> |
| 313 | + <rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:pdfuaid="http://www.aiim.org/pdfua/ns/id/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:desc="http://ns.adobe.com/xfa/promoted-desc/" rdf:about=""> |
| 314 | + <xmp:MetadataDate>2024-09-16T13:50:19Z</xmp:MetadataDate> |
| 315 | + <xmp:CreatorTool>Designer 6.5</xmp:CreatorTool> |
| 316 | + <pdfuaid:part>1</pdfuaid:part> |
| 317 | + <pdf:Producer>Designer 6.5</pdf:Producer> |
| 318 | + <xmpMM:DocumentID>uuid:79b538a1-6192-490d-b164-4afa39964215</xmpMM:DocumentID> |
| 319 | + <dc:description> |
| 320 | + <rdf:Alt> |
| 321 | + <rdf:li xml:lang="x-default">This form is used for performing a Smoke Test of an AEM instance. It exercises the Document Services APIs.</rdf:li> |
| 322 | + </rdf:Alt> |
| 323 | + </dc:description> |
| 324 | + <dc:creator> |
| 325 | + <rdf:Seq> |
| 326 | + <rdf:li>4Point Solutions</rdf:li> |
| 327 | + </rdf:Seq> |
| 328 | + </dc:creator> |
| 329 | + <dc:title> |
| 330 | + <rdf:Alt> |
| 331 | + <rdf:li xml:lang="x-default">Smoke Test</rdf:li> |
| 332 | + </rdf:Alt> |
| 333 | + </dc:title> |
| 334 | + <desc:version rdf:parseType="Resource"> |
| 335 | + <rdf:value>6.5.19.20231117.148</rdf:value> |
| 336 | + <desc:ref>/template/subform[1]</desc:ref> |
| 337 | + </desc:version> |
| 338 | + <desc:contact rdf:parseType="Resource"> |
| 339 | + <rdf:value>support@4point.com</rdf:value> |
| 340 | + <desc:ref>/template/subform[1]</desc:ref> |
| 341 | + </desc:contact> |
| 342 | + </rdf:Description> |
| 343 | + </rdf:RDF> |
| 344 | + </x:xmpmeta></xdp:xdp> |
| 345 | + """; |
| 346 | +} |
0 commit comments