Skip to content

Instantly share code, notes, and snippets.

View cfjedimaster's full-sized avatar
😺
Happy, and tired.

Raymond Camden cfjedimaster

😺
Happy, and tired.
View GitHub Profile
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}`,
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 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,
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.');
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', {
<!--- 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">
/*
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 = {};
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));
}
{
"version": "2.10.2",
"size": {
"width": 2048,
"height": 2048
},
"predictedContentClass": "art",
"outputs": [
{
"seed": 1613067352,
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: {