This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
import { Readable } from 'stream'; | |
import { finished } from 'stream/promises'; | |
let REST_API = "https://pdf-services.adobe.io/"; | |
let CLIENT_ID = process.env.CLIENT_ID; | |
let CLIENT_SECRET = process.env.CLIENT_SECRET; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
favorite_movie value lies outside the list values, setting custom text is not allowed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install @adobe/pdfservices-node-sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
ServicePrincipalCredentials, | |
PDFServices, | |
MimeType, | |
CreatePDFJob, | |
CreatePDFResult | |
} from '@adobe/pdfservices-node-sdk'; | |
import fs from 'fs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let CLIENT_ID = process.env.CLIENT_ID; | |
let CLIENT_SECRET = process.env.CLIENT_SECRET; | |
// Setup credentials | |
let credentials = new ServicePrincipalCredentials({ clientId: CLIENT_ID, clientSecret: CLIENT_SECRET }); | |
let pdfServices = new PDFServices({ credentials }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const inputAsset = await pdfServices.upload({ | |
readStream:fs.createReadStream('./input.docx'), | |
mimeType: MimeType.DOCX | |
}); | |
console.log(`Source doc uploaded, asset ID is ${inputAsset.assetId}`); | |
let job = new CreatePDFJob({inputAsset}); | |
let pollingURL = await pdfServices.submit({job}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let response = await pdfServices.getJobResult({ pollingURL, resultType: CreatePDFResult }); | |
let streamAsset = await pdfServices.getContent({ asset: response.result.asset}); | |
streamAsset.readStream.pipe(fs.createWriteStream('./output.pdf')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
ServicePrincipalCredentials, | |
PDFServices, | |
MimeType, | |
CreatePDFJob, | |
CreatePDFResult | |
} from '@adobe/pdfservices-node-sdk'; | |
import fs from 'fs'; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
ServicePrincipalCredentials, | |
PDFServices, | |
MimeType, | |
CreatePDFJob, | |
CreatePDFResult, | |
ProtectPDFParams, | |
EncryptionAlgorithm, | |
ProtectPDFJob, | |
ProtectPDFResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let response = await pdfServices.getJobResult({ pollingURL, resultType: CreatePDFResult }); |