This file contains hidden or 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
async function watermarkJob(source, watermark, token, clientId) { | |
let body = { | |
'inputDocumentAssetID': source.assetID, | |
'watermarkDocumentAssetID': watermark.assetID | |
} | |
let resp = await fetch(REST_API + 'operation/addwatermark', { | |
method: 'POST', | |
headers: { | |
'Authorization':`Bearer ${token}`, |
This file contains hidden or 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 hidden or 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
/* | |
This is hard coded, but in a real application would be dynamic: | |
*/ | |
let email = '[email protected]'; | |
async function documentGenerationJob(asset, outputFormat, data, token, clientId) { | |
let body = { | |
'assetID': asset.assetID, | |
'outputFormat': outputFormat, |
This file contains hidden or 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 sourceAsset = await getUploadData('application/pdf', accessToken, CLIENT_ID); | |
await uploadFile(sourceAsset.uploadUri, SOURCE_PDF, 'application/pdf'); | |
console.log('Source PDF Uploaded.'); | |
let sourceAsset = await getUploadData('application/pdf', accessToken, CLIENT_ID); | |
await uploadFile(sourceAsset.uploadUri, SOURCE_PDF, 'application/pdf'); | |
console.log('Source PDF Uploaded.'); | |
job = await watermarkJob(sourceAsset, docgenResult.asset, accessToken, CLIENT_ID); | |
console.log('Watermark Job created. Now to poll it.'); |
This file contains hidden or 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
async function watermarkJob(source, watermark, token, clientId) { | |
let body = { | |
'inputDocumentAssetID': source.assetID, | |
'watermarkDocumentAssetID': watermark.assetID, | |
'appearance': { | |
'opacity':33 | |
} | |
} | |
let resp = await fetch(REST_API + 'operation/addwatermark', { |
This file contains hidden or 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
<!--- first, read in the source ---> | |
<cfpdf action="read" source="source.pdf" name="source"> | |
<!--- add a header ---> | |
<cfpdf action="addHeader" source="source" text="Raymond Camden" align="right"> | |
<!--- merge with to merge ---> | |
<cfpdf action="merge" name="merged"> | |
<cfpdfparam source="source"> |
This file contains hidden or 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
/* | |
So, I struggled with the logic of - given we have 2 or 3 arrays, what items exist in ALL 3 | |
Idea by @falken on Masto | |
*/ | |
let numArrays = 0; | |
if(filter.title) numArrays++; | |
if(filter.duration) numArrays++; | |
if(filter.ingredient) numArrays++; | |
let idBag = {}; | |
let obBag = {}; |
This file contains hidden or 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
async function downloadFile(url, filePath) { | |
let res = await fetch(url); | |
const body = Readable.fromWeb(res.body); | |
const download_write_stream = fs.createWriteStream(filePath); | |
return await finished(body.pipe(download_write_stream)); | |
} |
This file contains hidden or 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
{ | |
"version": "2.10.2", | |
"size": { | |
"width": 2048, | |
"height": 2048 | |
}, | |
"predictedContentClass": "art", | |
"outputs": [ | |
{ | |
"seed": 1613067352, |
This file contains hidden or 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
async function textToImage(prompt, id, token) { | |
let body = { | |
"n":4, | |
prompt | |
} | |
let req = await fetch('https://firefly-api.adobe.io/v2/images/generate', { | |
method:'POST', | |
headers: { |