在AEM Forms中使用Forms服務呈現互動式PDF
最後更新: 2025年5月5日
- 適用對象:
- Experience Manager 6.4
- Experience Manager 6.5
建立對象:
- 中繼
- 開發人員
在AEM Forms中使用Forms Service API來呈現互動式PDF
在本文中,我們將瞭解以下服務
- FormsService — 這項功能非常廣泛的服務可讓您從PDF檔案匯出/匯入資料,也可以將xml資料合併到xdp範本中,產生互動式pdf
此處列出適用於AEM Forms API的官方javadoc
下列程式碼片段會使用FormsService的renderPDFForm作業來轉譯互動式pdf。 schengen.xdp是用於合併xml資料的範本。
String uri = "crx:///content/dam/formsanddocuments";
PDFFormRenderOptions renderOptions = new PDFFormRenderOptions();
renderOptions.setAcrobatVersion(AcrobatVersion.Acrobat_11);
renderOptions.setContentRoot(uri);
Document interactivePDF = null;
try {
interactivePDF = formsService.renderPDFForm("schengen.xdp", xmlData, renderOptions);
} catch (FormsServiceException e) {
e.printStackTrace();
}
return interactivePDF;
第1行:包含xdp範本的資料夾位置
Line2-4:建立PDFFormRenderOptions並設定其屬性
第7行:使用FormsService的renderPDFForm服務操作產生互動式PDF
第11行:將產生的互動式pdf傳回給呼叫應用程式
若要在您的系統上測試範例封裝
-
搜尋Adobe Granite CSRF篩選器
-
在排除的區段中新增以下路徑並儲存
-
/bin/generateinteractivepdf
-
搜尋 Apache Sling Service使用者對應程式服務,然後按一下以開啟屬性
- 按一下 + 圖示(加號)以新增下列服務對應
- DevelopingWithServiceUser.core:getformsresourceresolver=fd-service
- 按一下「儲存」
- 按一下 + 圖示(加號)以新增下列服務對應
-
填寫幾個欄位,然後按一下 下載並填寫…位 按鈕
-
互動式pdf應下載至您的本機系統
範例套件包含與行動表單相關聯的自訂設定檔。 請探索customtoolbar.jsp檔案。 此jsp會從行動表單中擷取資料,並對掛接在 /bin/generateinteractivepdf 路徑上的servlet發出POST請求。 此servlet會將互動式pdf傳回至呼叫的應用程式。 customtoolbar.jsp中的程式碼然後將檔案下載到您的本機系統
recommendation-more-help
8de24117-1378-413c-a581-01e660b7163e