Skip to content

Instantly share code, notes, and snippets.

View benvanderberg's full-sized avatar

Ben Vanderberg benvanderberg

View GitHub Profile
previewFilePromise.then(adobeViewer => {
adobeViewer.getAPIs().then(apis => {
apis.getSelectedContent()
.then(result => console.log(result))
.catch(error => console.log(error));
});
});
<html>
<head>
<title>Adobe Document Cloud PDF Embed API Sample</title>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1"/>
</head>
<body style="margin: 0px">
<div id="adobe-dc-view"></div>
const fields = ["dc:title", "dc:creator", "xmp:CreateDate"];
const includeRawStream = true;
previewFilePromise.then(adobeViewer => {
adobeViewer.getAPIs().then(apis => {
apis.getXMPMetadata(fields, includeRawStream)
.then(result => console.log(result))
.catch(error => console.log(error));
});
});
<script src="./json.js'></script>.
<body onload = "initial()">
<script src="./json.js"></script>
<script type="text/javascript">
/*
The initial() function merges information from the JSON you pass during document generation.
*/
// Converts numbers into currency
function currencyFormat(num) {
try {
// Initial setup, create credentials instance.
const credentials = DCServicesSdk.Credentials
.serviceAccountCredentialsBuilder()
.fromFile("dc-services-sdk-credentials.json")
.build();
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = DCServicesSdk.ExecutionContext.create(credentials),
htmlToPDFOperation = DCServicesSdk.CreatePDF.Operation.createNew();
const setCustomOptions = (htmlToPDFOperation) => {
// Define the page layout, in this case an 8 x 11.5 inch page (effectively portrait orientation).
const pageLayout = new DCServicesSdk.CreatePDF.options.PageLayout();
pageLayout.setPageSize(8, 11.5);
//Set the dataToMerge field that needs to be populated in the HTML before its conversion.
const dataToMerge = {
"invoiceNo":"123456",
try {
// Initial setup, create credentials instance.
const credentials = DCServicesSdk.Credentials
.serviceAccountCredentialsBuilder()
.fromFile("dc-services-sdk-credentials.json")
.build();
//Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = DCServicesSdk.ExecutionContext.create(credentials),
exportPDF = DCServicesSdk.ExportPDF,
const DCServicesSdk = require('@adobe/dc-services-node-sdk');
try {
// Initial setup, create credentials instance.
const credentials = DCServicesSdk.Credentials
.serviceAccountCredentialsBuilder()
.fromFile("dc-services-sdk-credentials.json")
.build();
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = DCServicesSdk.ExecutionContext.create(credentials),
adobeDCView.registerCallback(
/* Type of call back */
AdobeDC.View.Enum.CallbackType.EVENT_LISTENER,
/* call back function */
function(event) {
console.log(event);
},
{
enablePDFAnalytics: true,
}