Adobe PDF Services #NonPDF: Create PDF
Adobe PDF Services #NonPDF: PDFを作成
Creates PDF document from Non PDF Asset stored in the internal storage for PDF Services. Note that the job result (PDF file) will be obtained in an automated task that downloads it using the Polling-URI in the downstream process.
Configs for this Auto Step
- AuthzConfU1
- U1: Select Authz for PDF-SERVICES-API Client ID (Fixed Value) *
- AuthzConfU2
- U2: Select Authz for PDF-SERVICES-API Client Secret (FixedValue) *
- StrConfA1
- A1: Set AssetID *#{EL}
- StrConfA2
- A2: Set Document Language (eg “ja-JP”, “en-US”)#{EL}
- SelectConfB1
- B1: Select STRING that stores PollingURI (update) *
- StrConfU3
- U3: Set {regionCode} to process in a specified region (“ew1”)#{EL}
Script (click to open)
// GraalJS standard mode Script Script (engine type: 3)
// cf. 'engine type: 2': "GraalJS Nashorn compatible mode" (renamed from "GraalJS" at 20230526)
//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){
////// == Config Retrieving / 工程コンフィグの参照 ==
const strAuthzId = configs.get( "AuthzConfU1" ); /// REQUIRED
engine.log( " AutomatedTask Config: Authz ID: " + strAuthzId );
const strClientId = httpClient.getOAuth2Token( strAuthzId );
if ( strClientId === "" ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {U1: ClientId} is empty \n" );
}
const strAuthzSecret = configs.get( "AuthzConfU2" ); /// REQUIRED
engine.log( " AutomatedTask Config: Authz SECRET: " + strAuthzSecret );
const strClientSecret = httpClient.getOAuth2Token( strAuthzSecret );
if ( strClientSecret === "" ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {U2: ClientSecret} is empty \n" );
}
const strRegionCode = configs.get( "StrConfU3" ); // Not Required
let strRegionPostfix = strRegionCode !== "" ? ("-" + strRegionCode) : "";
engine.log( " AutomatedTask Config: strRegionPostfix: " + strRegionPostfix );
// https://developer.adobe.com/document-services/docs/overview/pdf-services-api/howtos/service-region-configuration-for-apis/
const strAssetId = configs.get( "StrConfA1" ); /// REQUIRED
const strDocumentLanguage = configs.get( "StrConfA2" ); // Not Required
const strPocketLocation = configs.getObject( "SelectConfB1" ); /// REQUIRED
////// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)
////// == Calculating / 演算 ==
//// Adobe Developer > PDF Services API > Generate Token
//// Generate access token to perform PDF Services operations
//// https://developer.adobe.com/document-services/docs/apis/#tag/Generate-Token
/// prepare request1
let request1Uri = "https://pdf-services" + strRegionPostfix + ".adobe.io/token";
let request1 = httpClient.begin(); // HttpRequestWrapper
/// prepare application/x-www-form-urlencoded
request1 = request1.formParam ( "client_id", strClientId );
request1 = request1.formParam ( "client_secret", strClientSecret );
/// try request1
const response1 = request1.post( request1Uri ); // HttpResponseWrapper
engine.log( " AutomatedTask ApiRequest1 Start: " + request1Uri );
const response1Code = response1.getStatusCode() + ""; // JavaNum to string
const response1Body = response1.getResponseAsString();
engine.log( " AutomatedTask ApiResponse1 Status: " + response1Code );
if( response1Code !== "200"){
throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
response1Code + "\n" + response1Body + "\n" );
}
/* engine.log( response1Body ); // debug
{
"access_token":"xxxxxxxxxx975yyyyyyyyyy",
"token_type":"bearer",
"expires_in":86399
}
*/
/// parse response1 (OAuth Server-to-Server)
const response1Obj = JSON.parse( response1Body );
const strAccessToken = response1Obj.access_token;
//// Adobe Developer > PDF Services API > Assets
//// Create PDF document from non PDF document.
//// https://developer.adobe.com/document-services/docs/apis/#tag/Create-PDF/operation/pdfoperations.createpdf
/// prepare request2
let request2Uri = "https://pdf-services" + strRegionPostfix + ".adobe.io" +
"/operation/createpdf";
let request2 = httpClient.begin(); // HttpRequestWrapper
/// prepare header parameters
request2 = request2.bearer ( strAccessToken );
request2 = request2.header ( "x-api-key", strClientId );
/// prepare application/json
let strJson = {};
strJson.assetID = strAssetId;
if ( strDocumentLanguage !== "" ) {
strJson.documentLanguage = strDocumentLanguage;
}
request2 = request2.body ( JSON.stringify( strJson ), "application/json" );
/// try request2
const response2 = request2.post ( request2Uri ); // HttpResponseWrapper
engine.log( " AutomatedTask ApiRequest2 Start: " + request2Uri );
const response2Code = response2.getStatusCode() + ""; // JavaNum to string
const response2Body = response2.getResponseAsString();
engine.log( " AutomatedTask ApiResponse2 Status: " + response2Code );
if( response2Code !== "201"){ // not 200
throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
response2Code + "\n" + response2Body + "\n" );
}
const strLocation = response2.getHeaderValues ( "location" ).get(0);
/* engine.log( " AutomatedTask ApiResponse2 HEADER Location: " + strLocation );
AutomatedTask ApiResponse2 HEADER Location: https://pdf-services-ue1.adobe.io/operation/createpdf/xxxxxyyyyyzzzzzwwwwwXXXXXYYYYYZZ/status
*/
/* engine.log( response2Body ); // debug
null
*/
////// == Data Updating / ワークフローデータへの代入 ==
if( strPocketLocation !== null ){
engine.setData( strPocketLocation, strLocation );
}
} //////// END "main()" /////////////////////////////////////////////////////////////////
/*
Notes:
- If you place this "Automated Step" in the Workflow diagram, the request will be automatically sent every time the process token arrives.
- A request is automatically sent to the Adobe PDF Services API server. (REST API)
- The response from the Adobe PDF Services API server is automatically parsed.
- This "Automated Step" will automatically convert files (Asset) stored in Adobe internal storage to PDF.
- Supported file formats are bmp, doc, docx, gif, jpeg, jpg, png, ppt, pptx, rtf, tif, tiff, txt, xls and xlsx.
- https://developer.adobe.com/document-services/docs/apis/#tag/Create-PDF/operation/pdfoperations.createpdf
- Automated task that downloads it using the Polling-URI:
- "Adobe PDF Services #Results: Download"
- https://support.questetra.com/addons/adobe-pdf-services-results-download-2023/
- To activate a Workflow App that includes this Automated Step, "HTTP Authz Setting" is required
- Set Credentials to "Token Fixed Value" in Workflow App.
- Obtain Credentials ("Client ID" and "Client Secret") in advance.
- https://acrobatservices.adobe.com/dc-integration-creation-app-cdn/main.html?api=pdf-services-api
- Adobe Developer Console
- https://developer.adobe.com/console/projects
APPENDIX
- PDF Services:
- Essential PDF tools to store and share files online, as well as create, combine, export, organize, and fill & sign documents.
- https://helpx.adobe.com/enterprise/using/optional-services.html
- PDF Services API to automate for your document workflows
- create a PDF from a dynamic HTML report
- set a password to prevent unauthorized opening of the document
- compress it for sharing as an attachment
- extract text, tables, images and document structure to enable downstream solutions
- https://developer.adobe.com/document-services/docs/overview/#pdf-services-api-to-automate-for-your-document-workflows
- Adobe PDF Services API Free Tier
- 500 freeDocument Transactions per month. No credit card required. (asof 202306)
- https://developer.adobe.com/document-services/docs/overview/limits/#usage-limits
Notes-ja:
- この[自動工程]をワークフロー図に配置すれば、案件が到達する度にリクエストが自動送信されます。
- Adobe PDF Services API サーバに対してリクエストが自動送出されます。(REST API通信)
- Adobe PDF Services API サーバからのレスポンスが自動保存解析されます。
- この[自動工程]は、Adobe 内部ストレージに保存されているファイル(Asset)をPDFに自動変換します。
- サポートフォーマット: bmp, doc, docx, gif, jpeg, jpg, png, ppt, pptx, rtf, tif, tiff, txt, xls and xlsx.
- https://developer.adobe.com/document-services/docs/apis/#tag/Create-PDF/operation/pdfoperations.createpdf
- Polling-URI を用いてファイルをダウンロードする自動工程
- "Adobe PDF Services #成果物: ダウンロード"
- https://support.questetra.com/ja/addons/adobe-pdf-services-results-download-2023/
- この[アドオン自動工程]を含むワークフローアプリを運用するには[HTTP 認証設定]が必要です。
- Credentials はワークフローアプリの[トークン直接指定]にセットします。
- あらかじめ Credentials ("Client ID" および "Client Secret") を取得しておいてください。
- https://acrobatservices.adobe.com/dc-integration-creation-app-cdn/main.html?api=pdf-services-api
- Adobe Developer Console
- https://developer.adobe.com/console/projects
APPENDIX-ja
- PDF Servicesとは
- ファイルのオンラインでの保存、共有のほか、ドキュメントの作成、結合、書き出し、整理、入力と署名を行うための PDF 基本ツールです。
- https://helpx.adobe.com/jp/enterprise/using/optional-services.html
- Document ワークフローを自動化する PDF Services API
- 動的 HTML レポートから PDF を簡単に作成
- ドキュメントが不正に開かれないようにパスワードを設定
- 添付ファイルとして共有するために圧縮
- テキスト、表、画像、ドキュメント構造を抽出してダウンストリーム ソリューションを実現
- https://developer.adobe.com/document-services/docs/overview/#pdf-services-api-to-automate-for-your-document-workflows
- Adobe PDF Services API の無料利用枠
- 毎月500件の無料ドキュメントトランザクション。クレジットカードは必要なし。(202306現在)
- https://developer.adobe.com/document-services/docs/overview/limits/#usage-limits
*/
Download
- adobe-pdf-services-nonpdf-create-pdf-2023.xml
- 2023-07-03 (C) Questetra, Inc. (MIT License)
(Installing Addon Auto-Steps are available only on the Professional edition.)
Notes
- If you place this “Automated Step” in the Workflow diagram, the request will be automatically sent every time the process token arrives.
- A request is automatically sent to the Adobe PDF Services API server. (REST API)
- The response from the Adobe PDF Services API server is automatically parsed.
- This “Automated Step” will automatically convert files (Asset) stored in Adobe internal storage to PDF.
- Supported file formats are bmp, doc, docx, gif, jpeg, jpg, png, ppt, pptx, rtf, tif, tiff, txt, xls and xlsx.
- https://developer.adobe.com/document-services/docs/apis/#tag/Create-PDF/operation/pdfoperations.createpdf
- Automated task that downloads it using the Polling-URI:
- “Adobe PDF Services #Results: Download”
- https://support.questetra.com/addons/adobe-pdf-services-results-download-2023/
- To activate a Workflow App that includes this Automated Step, “HTTP Authz Setting” is required
- Set Credentials to “Token Fixed Value” in Workflow App.
- Obtain Credentials (“Client ID” and “Client Secret”) in advance.
- Adobe Developer Console
Capture

Appendix
- PDF Services:
- Essential PDF tools to store and share files online, as well as create, combine, export, organize, and fill & sign documents.
- https://helpx.adobe.com/enterprise/using/optional-services.html
- PDF Services API to automate for your document workflows
- create a PDF from a dynamic HTML report
- set a password to prevent unauthorized opening of the document
- compress it for sharing as an attachment
- extract text, tables, images and document structure to enable downstream solutions
- https://developer.adobe.com/document-services/docs/overview/#pdf-services-api-to-automate-for-your-document-workflows
- Adobe PDF Services API Free Tier
- 500 freeDocument Transactions per month. No credit card required. (asof 202306)
- https://developer.adobe.com/document-services/docs/overview/limits/#usage-limits