在AEM Forms中使用輸出和Forms服務API
在本文中,我們將審視以下內容
下列程式碼片段會從PDF檔案匯出資料
javax.servlet.http.Part pdfPart = request.getPart("pdffile");
String filePath = request.getParameter("saveLocation");
java.io.InputStream pdfIS = pdfPart.getInputStream();
com.adobe.aemfd.docmanager.Document pdfDocument = new com.adobe.aemfd.docmanager.Document(pdfIS);
com.adobe.fd.forms.api.FormsService formsservice = sling.getService(com.adobe.fd.forms.api.FormsService.class);
com.adobe.aemfd.docmanager.Document xmlDocument = formsservice.exportData(pdfDocument,com.adobe.fd.forms.api.DataFormat.Auto);
第1行會從請求中擷取檔案
第2行會從請求中擷取saveLocation
第5行獲得FormsService
第6行從PDF檔案導出xmlData
在系統上測試示例包
安裝套件後,您必須在AdobeGranite CSRF篩選器中允許列出下列URL。
確認您已從下拉式清單http://localhost:4502/content/AemFormsSamples/exportdata.html中選取「POST」。請確定您將「授權」指定為「基本驗證」。 指定AEM伺服器使用者名稱和密碼導覽至「Body」標籤,並指定要求參數,如下圖所示
然後按一下「傳送」按鈕
包含3個樣本。 以下各段說明何時使用輸出服務或Forms服務(服務的url),輸入每個服務所需的參數
使用輸出服務來合併資料與xdp或pdf檔案,以產生平面化的pdf
POSTURL:http://localhost:4502/content/AemFormsSamples/outputservice.html
請求參數 —
使用FormsService將資料匯入PDF檔案
POSTURL - http://localhost:4502/content/AemFormsSamples/mergedata.html
請求參數:
c:\\outputsample.pdf
.從PDF檔案匯出資料
使用FormsService從PDF檔案匯出資料
POSTUR L - http://localhost:4502/content/AemFormsSamples/exportdata.html
請求參數: