Skip to content

Instantly share code, notes, and snippets.

Avatar
😺
Happy, and tired.

Raymond Camden cfjedimaster

😺
Happy, and tired.
View GitHub Profile
View temp.cfc
//remove existing output if it's there
output = expandPath('./helloworld2.pdf');
if(fileExists(output)) fileDelete(output);
// create and setup credentials
cred = createObject('java','com.adobe.platform.operation.auth.Credentials');
jsonFile = expandPath('./pdftools-api-credentials.json');
credentials = cred.serviceAccountCredentialsBuilder().fromFile(jsonFile).build();
// this sets up what we want to do, create a pdf
View temp.cfm
cred = createObject('java','com.adobe.platform.operation.auth.Credentials');
jsonFile = expandPath('./pdftools-api-credentials.json');
credentials = cred.serviceAccountCredentialsBuilder().fromFile(jsonFile).build();
View temp.java
Credentials credentials = Credentials.serviceAccountCredentialsBuilder()
.fromFile("pdfservices-api-credentials.json")
.build();
View Application.cfc
component {
this.name = 'Sample Application';
// Load in my custom Java coolnesss
this.javaSettings.loadPaths = [expandPath('./jars')];
// more code here typically
}
View sample.js
// Set operation input from a source file.
const input = PDFServicesSdk.FileRef.createFromURL("https://www.adobe.io");
htmlToPDFOperation.setInput(input);
View sample.js
exportPdfToImagesOperation.execute(executionContext)
.then(result => {
let saveFilesPromises = [];
for(let i = 0; i < result.length; i++){
saveFilesPromises.push(result[i].saveAsFile(`output/exportPDFToJPEGOutput_${i}.jpeg`));
}
return Promise.all(saveFilesPromises);
})
.catch(err => {
if(err instanceof PDFServicesSdk.Error.ServiceApiError
View sample.json
{
"pages": [
{
"page_number": 0,
"is_scanned": false,
"width": 596,
"has_structure": false,
"content": {
"number_of_images": 0,
"only_images": false,
View main.js
const nanoid = require('nanoid').nanoid;
let output = '/tmp/' + nanoid() + '.pdf';
View multi.js
const pdfSDK = require('@adobe/pdfservices-node-sdk');
const fs = require('fs');
(async ()=> {
const input = './hamlet2.docx';
const output = './multi.pdf';
const creds = './pdftools-api-credentials.json';
if(fs.existsSync(output)) fs.unlinkSync(output);
View main.js
let fixedKey = process.env.ADOBE_KEY.replace(/\\n/g, '\n');