Adobe PDF Embed API
Free JavaScript API to embed high-fidelity PDFs, enable collaboration, and see analytics Try the demo
Try the demoAccurate, consistent PDF rendering
Whether on dynamic or static pages, deliver the highest quality PDF rendering available
Customizable user experience
Choose exactly how to display a PDF and use the callbacks and annotations APIs to provide programmatic control and enable digital collaboration
Analytics on PDF usage
Use analytics to understand how users interact with PDFs, including time spent on a page and searches
Key Features of Our free PDF Embed API
-
Embed Modes
Embed Modes
Control how you embed PDFs, with support for full-sized windows, sized containers, in-line display, and lightboxes
See documentation -
Annotations
Annotations
Full support for import, create, delete, update, exporting of comments, and more; programmatically add, update, and delete annotations with the option to save; events can be triggered based on user actions
See documentation -
PDF Analytics
PDF Analytics
Easily integrate Adobe Analytics with only a few steps, or leverage the user events to push data to other analytics tools
See documentation -
Collaborative Settings
Collaborative Settings
For multi-user document collaboration, identify reviewers by name or email address and save annotation settings through custom callbacks (default settings display GUEST as the reviewer name for all comments)
See documentation -
Save Controls
Save Controls
Support auto-save to local drives or external storage, with options for frequency and polling, along with success/fail events capture; use file modification and status polling events for multi-user workflows
See documentation -
Menu & Tool Options
Menu & Tool Options
Programmatically enable or disable the left-hand panel, comments pane, toolbars, print, and download options
See Documentation
Embed Modes
Control how you embed PDFs, with support for full-sized windows, sized containers, in-line display, and lightboxes
See documentation
curl --location --request POST 'https://cpf-stage-ue1.adobe.io/ops/:create' \
--header 'Accept: application/json, text/plain, /' \
--header 'Authorization: Bearer ' \
--header 'x-api-key: ' \
--form 'contentAnalyzerRequests={
\"cpf:engine\": {
\"repo:assetId\": \"urn:aaid:cpf:58af6e2c-1f0c-400d-9188-078000185695\"
},
\"cpf:inputs\": {
\"documentIn\": {
\"cpf:location\": \"fileInput1\",
\"dc:format\": \"application/pdf\"
},
\"params\": {
\"cpf:inline\": {
\"elementsToExtract\": [
\"text\", \"tables\"
],
\"renditionsToExtract\": [ \"tables\", \"figures\"]
}
}
},
\"cpf:outputs\": {
\"elementsInfo\": {
\"cpf:location\": \"jsonoutput\",
\"dc:format\": \"application/json\"
},
\"elementsRenditions\": {
\"cpf:location\": \"fileoutpart\",
\"dc:format\": \"text/directory\"
}
}
}' \
--form 'fileInput1=@""'
// Create an ExecutionContext using credentials
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);
// Create a new operation instance.
const extractPDFOperation = PDFServicesSdk.ExtractPDF.Operation.createNew(),
input = PDFServicesSdk.FileRef.createFromLocalFile(
'resources/extractPDFInput.pdf',
PDFServicesSdk.ExtractPDF.SupportedSourceFormat.pdf
);
// Set operation input from a source file.
extractPDFOperation.setInput(input);
// Build and set extractPDF options
const options = new PDFServicesSdk.ExtractPDF.options.ExtractPdfOptions.Builder()
.addElementsToExtract(
PDFServicesSdk.ExtractPDF.options.ExtractElementType.TEXT)
.addElementsToExtractRenditions(
PDFServicesSdk.ExtractPDF.options.ExtractRenditionsElementType.FIGURES)
.addCharInfo(true)
.build()
extractPDFOperation.setOptions(options);
// Execute the operation and Save the result to the specified location.
extractPDFOperation.execute(executionContext)
.then(result => result.saveAsFile('output/extractPdf.zip'))
//Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
ExtractPDFOperation extractPdfOperation = ExtractPDFOperation.CreateNew();
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"extractPDFInput.pdf");
extractPdfOperation.SetInputFile(sourceFileRef);
// Build ExtractPDF options and set them into the operation
ExtractPDFOptions extractPdfOptions = ExtractPDFOptions.ExtractPdfOptionsBuilder()
.AddElementsToExtract(new List(new []{ ExtractElementType.TEXT, ExtractElementType.TABLES}))
.AddElementsToExtractRenditions(new List (new []{ExtractRenditionsElementType.FIGURES, ExtractRenditionsElementType.TABLES}))
.AddAddCharInfo(true)
.build();
extractPdfOperation.SetOptions(extractPdfOptions);
// Execute the operation.
FileRef result = extractPdfOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() + "/output/ExtractTextTableInfoWithFiguresTablesRenditionsFromPDF.zip");
// Create an ExecutionContext using credentials and create a new operation instance
ExecutionContext executionContext = ExecutionContext.create(credentials);
ExtractPDFOperation extractPDFOperation = ExtractPDFOperation.createNew();
// Set operation input from a source file
FileRef source = FileRef.createFromLocalFile("src/test/resources/extractPdfInput.pdf");
extractPDFOperation.setInputFile(source);
// Build ExtractPDF options and set them into the operation
ExtractPDFOptions extractPDFOptions = ExtractPDFOptions.extractPdfOptionsBuilder()
.addElementsToExtract(Arrays.asList(PDFElementType.TEXT, PDFElementType.TABLES))
.addElementsToExtractRenditions(Arrays.asList(PDFElementType.TABLES, PDFElementType.FIGURES))
.addCharInfo(Boolean.TRUE)
.build();
extractPDFOperation.setOptions(extractPDFOptions);
// Execute the operation
FileRef result = extractPDFOperation.execute(executionContext);
// Save the result at the specified location
result.saveAs("output/extractPdf.zip");
#Create an ExecutionContext using credentials and create a new operation instance.
execution_context = ExecutionContext.create(credentials)
extract_pdf_operation = ExtractPDFOperation.create_new()
#Set operation input from a source file.
source = FileRef.create_from_local_file(base_path + "/resources/extractPdfInput.pdf")
extract_pdf_operation.set_input(source)
# Build ExtractPDF options and set them into the operation
extract_pdf_options: ExtractPDFOptions = ExtractPDFOptions.builder() \
.with_elements_to_extract([PDFElementType.TEXT, PDFElementType.TABLES]) \
.with_elements_to_extract_renditions([PDFElementType.TABLES, PDFElementType.FIGURES]) \
.with_get_char_info(True) \
.build()
extract_pdf_operation.set_options(extract_pdf_options)
#Execute the operation.
result: FileRef = extract_pdf_operation.execute(execution_context)
# Save the result to the specified location.
result.save_as(base_path + "/output/extractPdf.zip")
curl --location --request POST 'https://cpf-ue1.adobe.io/ops/:create?respondWith=%7B%22reltype%22%3A%20%22http%3A%2F%2Fns.adobe.com%2Frel%2Fprimary%22%7D' \
--header 'Authorization: Bearer ' \
--header 'Accept: application/json, text/plain, */*' \
--header 'x-api-key: ' \
--header 'Prefer: respond-async,wait=0' \
--form 'contentAnalyzerRequests="{
\"cpf:inputs\": {
\"documentIn\": {
\"cpf:location\": \"InputFile0\",
\"dc:format\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"
}
},
\"cpf:engine\": {
\"repo:assetId\": \"urn:aaid:cpf:Service-1538ece812254acaac2a07799503a430\"
},
\"cpf:outputs\": {
\"documentOut\": {
\"cpf:location\": \"multipartLabelOut\",
\"dc:format\": \"application/pdf\"
}
}
}"' \
--form 'InputFile0=@""'
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
createPDF = PDFServicesSdk.CreatePDF,
htmlToPDFOperation = createPDF.Operation.createNew();
// Set operation input from a source URL.
const input = PDFServicesSdk.FileRef.createFromURL("https://www.adobe.io");
htmlToPDFOperation.setInput(input);
// Provide any custom configuration options for the operation.
const options = new createPDF.options.html.CreatePDFFromHtmlOptions.Builder()
.includesHeaderFooter(true)
.build();
htmlToPDFOperation.setOptions(options);
// Execute the operation and Save the result to the specified location.
htmlToPDFOperation.execute(executionContext)
.then(result => result.saveAsFile('output/createPdfFromURLOutput.pdf'))
//Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
CreatePDFOperation htmlToPDFOperation = CreatePDFOperation.CreateNew();
// Set operation input from a source URL.
FileRef source = FileRef.CreateFromURI(new Uri("https://www.adobe.io"));
htmlToPDFOperation.SetInput(source);
// Provide any custom configuration options for the operation.
SetCustomOptions(htmlToPDFOperation);
// Execute the operation.
FileRef result = htmlToPDFOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() + "/output/createPdfFromURLOutput.pdf");
//Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
CreatePDFOperation htmlToPDFOperation = CreatePDFOperation.createNew();
// Set operation input from a source file.
FileRef source = FileRef.createFromURL(new URL("https://www.adobe.io"));
htmlToPDFOperation.setInput(source);
// Provide any custom configuration options for the operation.
CreatePDFOptions htmlToPdfOptions = CreatePDFOptions.htmlOptionsBuilder()
.includeHeaderFooter(true)
.build();
htmlToPDFOperation.setOptions(htmlToPdfOptions);
// Provide any custom configuration options for the operation.
setCustomOptions(htmlToPDFOperation);
// Execute the operation.
FileRef result = htmlToPDFOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/createPDFFromURLOutput.pdf");
// Create an ExecutionContext using
// credentials and create a new
// operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
exportPDF = PDFServicesSdk.ExportPDF,
exportPdfOperation = exportPDF.Operation.createNew(exportPDF.SupportedTargetFormats.DOCX);
// Set operation input from a source file
const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/exportPDFInput.pdf');
exportPdfOperation.setInput(input);
// Execute the operation and Save the result to the specified location.
exportPdfOperation.execute(executionContext)
.then(result => result.saveAsFile('output/exportPdfOutput.docx'))
// Create an ExecutionContext using
// credentials and create a new
// operation instance.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
ExportPDFOperation exportPdfOperation = ExportPDFOperation.CreateNew( ExportPDFTargetFormat.DOCX );
// Set operation input from a local PDF file
FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"exportPdfInput.pdf");
exportPdfOperation.SetInput(sourceFileRef);
// Execute the operation.
FileRef result = exportPdfOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory()
+ "/output/exportPdfOutput.docx");
// Create an ExecutionContext using
// credentials and create a new
// operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
ExportPDFOperation exportPdfOperation = ExportPDFOperation
.createNew(ExportPDFTargetFormat.DOCX);
// Set operation input from a local PDF file
FileRef sourceFileRef = FileRef
.createFromLocalFile(
"src/main/resources/exportPDFInput.pdf"
);
exportPdfOperation.setInput(sourceFileRef);
// Execute the operation.
FileRef result = exportPdfOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/exportPdfOutput.docx");
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
ocrOperation = PDFServicesSdk.OCR.Operation.createNew();
// Set operation input from a source file.
const input = PDFServicesSdk.FileRef.createFromLocalFile( 'resources/ocrInput.pdf', PDFServicesSdk.OCR.SupportedMediaTypes.pdf );
ocrOperation.setInput(input);
// Execute the operation and Save the result to the specified location.
ocrOperation.execute(executionContext)
.then(result => result.saveAsFile('output/ocrOutput.pdf'));
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
OCROperation ocrOperation = OCROperation.CreateNew();
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"ocrInput.pdf");
ocrOperation.SetInput(sourceFileRef);
// Execute the operation.
FileRef result = ocrOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() + "/output/ocrOperationOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
OCROperation ocrOperation = OCROperation.createNew();
// Set operation input from a source file.
FileRef source = FileRef.createFromLocalFile( "src/main/resources/ocrInput.pdf" );
ocrOperation.setInput(source);
// Execute the operation
FileRef result = ocrOperation.execute(executionContext);
// Save the result at the specified location
result.saveAs("output/ocrOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
rotatePagesOperation = PDFServicesSdk.RotatePages.Operation.createNew();
// Set operation input from a source file.
const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/rotatePagesInput.pdf');
rotatePagesOperation.setInput(input);
// Sets angle by 90 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.
const firstPageRange = getFirstPageRangeForRotation();
rotatePagesOperation.setAngleToRotatePagesBy(PDFServicesSdk.RotatePages.Angle._90, firstPageRange);
// Sets angle by 180 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.
const secondPageRange = getSecondPageRangeForRotation();
rotatePagesOperation.setAngleToRotatePagesBy(PDFServicesSdk.RotatePages.Angle._180,secondPageRange);
// Execute the operation and Save the result to the specified location.
rotatePagesOperation.execute(executionContext)
.then(result => result.saveAsFile('output/rotatePagesOutput.pdf'));
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
// Create a new operation instance
RotatePagesOperation rotatePagesOperation = RotatePagesOperation.CreateNew();
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.CreateFromLocalFile(
@"rotatePagesInput.pdf"
);
rotatePagesOperation.SetInput(sourceFileRef);
// Sets angle by 90 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.
PageRanges firstPageRange = GetFirstPageRangeForRotation();
rotatePagesOperation.SetAngleToRotatePagesBy(
Angle._90, firstPageRange
);
// Sets angle by 180 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.
PageRanges secondPageRange = GetSecondPageRangeForRotation();
rotatePagesOperation
.SetAngleToRotatePagesBy(Angle._180, secondPageRange);
// Execute the operation.
FileRef result = rotatePagesOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() +
"/output/rotatePagesOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
RotatePagesOperation rotatePagesOperation = RotatePagesOperation.createNew();
// Set operation input from a source file.
FileRef source = FileRef.createFromLocalFile(
"src/main/resources/rotatePagesInput.pdf"
);
rotatePagesOperation.setInput(source);
// Sets angle by 90 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.
PageRanges firstPageRange = getFirstPageRangeForRotation();
rotatePagesOperation.setAngleToRotatePagesBy(
Angle._90, firstPageRange
);
// Sets angle by 180 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.
PageRanges secondPageRange = getSecondPageRangeForRotation();
rotatePagesOperation
.setAngleToRotatePagesBy(
Angle._180, secondPageRange
);
// Execute the operation.
FileRef result = rotatePagesOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/rotatePagesOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
deletePagesOperation = PDFServicesSdk.DeletePages.Operation.createNew();
// Set operation input from a source file.
const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/deletePagesInput.pdf');
deletePagesOperation.setInput(input);
// Delete pages of the document (as specified by PageRanges).
const pageRangesForDeletion = getPageRangesForDeletion();
deletePagesOperation.setPageRanges(pageRangesForDeletion);
// Execute the operation and Save the result to the specified location.
deletePagesOperation.execute(executionContext)
.then(result => result.saveAsFile('output/deletePagesOutput.pdf'))
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
// Create a new operation instance
DeletePagesOperation deletePagesOperation = DeletePagesOperation.CreateNew();
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.CreateFromLocalFile(
@"deletePagesInput.pdf"
);
deletePagesOperation.SetInput(sourceFileRef);
// Delete pages of the document
// (as specified by PageRanges).
PageRanges pageRangeForDeletion = GetPageRangeForDeletion();
deletePagesOperation
.SetPageRanges(pageRangeForDeletion);
// Execute the operation.
FileRef result = deletePagesOperation
.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() +
"/output/deletePagesOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
DeletePagesOperation deletePagesOperation = DeletePagesOperation.createNew();
// Set operation input from a source file.
FileRef source = FileRef.createFromLocalFile(
"src/main/resources/deletePagesInput.pdf"
);
deletePagesOperation.setInput(source);
// Delete pages of the document (as specified by PageRanges).
PageRanges pageRangeForDeletion = getPageRangeForDeletion();
deletePagesOperation.setPageRanges(pageRangeForDeletion);
// Execute the operation.
FileRef result = deletePagesOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/deletePagesOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
replacePagesOperation = PDFServicesSdk.ReplacePages.Operation.createNew();
// Set operation base input from a source file.
const baseInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/baseInput.pdf');
replacePagesOperation.setBaseInput(baseInputFile);
// Create a FileRef instance using a local file.
const firstInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/replacePagesInput1.pdf'),
pageRanges = getPageRangesForFirstFile();
// Adds the pages (specified by the page ranges) of the input PDF file for replacing the page of the base PDF file.
replacePagesOperation.addPagesForReplace(1, firstInputFile, pageRanges);
// Create a FileRef instance using a local file.
const secondInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/replacePagesInput2.pdf');
// Adds all the pages of the input PDF file for replacing the page of the base PDF file.
replacePagesOperation.addPagesForReplace(3, secondInputFile);
// Execute the operation and Save the result to the specified location.
replacePagesOperation.execute(executionContext)
.then(result => result.saveAsFile('output/replacePagesOutput.pdf'))
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
// Create a new operation instance
ReplacePagesOperation replacePagesOperation = ReplacePagesOperation.CreateNew();
// Set operation base input from a source file.
FileRef baseSourceFile = FileRef.CreateFromLocalFile(@"baseInput.pdf");
replacePagesOperation.SetBaseInput(baseSourceFile);
// Create a FileRef instance using a local file.
FileRef firstInputFile = FileRef.CreateFromLocalFile(
@"replacePagesInput1.pdf"
);
PageRanges pageRanges = GetPageRangeForFirstFile();
// Adds the pages (specified by the page ranges) of the input PDF file for replacing the page of the base PDF file.
replacePagesOperation
.AddPagesForReplace(firstInputFile, pageRanges, 1);
// Create a FileRef instance using a local file.
FileRef secondInputFile = FileRef.CreateFromLocalFile(
@"replacePagesInput2.pdf"
);
// Adds all the pages of the input PDF file for replacing the page of the base PDF file.
replacePagesOperation
.AddPagesForReplace(secondInputFile, 3);
// Execute the operation.
FileRef result = replacePagesOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() +
"/output/replacePagesOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
ReplacePagesOperation replacePagesOperation = ReplacePagesOperation.createNew();
// Set operation base input from a source file.
FileRef baseSourceFile = FileRef.createFromLocalFile(
"src/main/resources/baseInput.pdf"
);
replacePagesOperation.setBaseInput(baseSourceFile);
// Create a FileRef instance using a local file.
FileRef firstInputFile = FileRef.createFromLocalFile(
"src/main/resources/replacePagesInput1.pdf"
);
PageRanges pageRanges = getPageRangeForFirstFile();
// Adds the pages (specified by the page ranges) of the input PDF file for replacing the page of the base PDF file.
replacePagesOperation.addPagesForReplace(
firstInputFile, pageRanges, 1
);
// Create a FileRef instance using a local file.
FileRef secondInputFile = FileRef.createFromLocalFile(
"src/main/resources/replacePagesInput2.pdf"
);
// Adds all the pages of the input PDF file for replacing the page of the base PDF file.
replacePagesOperation
.addPagesForReplace(secondInputFile, 3);
// Execute the operation
FileRef result = replacePagesOperation.execute(executionContext);
// Save the result at the specified location
result.saveAs("output/replacePagesOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
linearizePDF = PDFServicesSdk.LinearizePDF,
linearizePDFOperation = linearizePDF.Operation.createNew();
// Set operation input from a source file.
const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/linearizePDFInput.pdf');
linearizePDFOperation.setInput(input);
// Execute the operation and Save the result to the specified location.
linearizePDFOperation.execute(executionContext)
.then(result => result.saveAsFile('output/linearizePDFOutput.pdf'))
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
LinearizePDFOperation linearizePDFOperation = LinearizePDFOperation.CreateNew();
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.CreateFromLocalFile(
@"linearizePDFInput.pdf"
);
linearizePDFOperation.SetInput(sourceFileRef);
// Execute the operation.
FileRef result = linearizePDFOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() +
"/output/linearizePDFOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
LinearizePDFOperation linearizePDFOperation = LinearizePDFOperation.createNew();
// Set operation input from a source file.
FileRef source = FileRef.createFromLocalFile(
"src/main/resources/linearizePDFInput.pdf" );
linearizePDFOperation.setInput(source);
// Execute the operation
FileRef result = linearizePDFOperation.execute(executionContext);
// Save the result at the specified location
result.saveAs("output/linearizePDFOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
compressPDF = PDFServicesSdk.CompressPDF,
compressPDFOperation = compressPDF.Operation.createNew();
// Set operation input from a source file.
const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/compressPDFInput.pdf');
compressPDFOperation.setInput(input);
// Execute the operation and Save the result to the specified location.
compressPDFOperation.execute(executionContext)
.then(result => result.saveAsFile('output/compressPDFOutput.pdf'))
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext =
ExecutionContext.Create(credentials);
CompressPDFOperation compressPDFOperation =
CompressPDFOperation.CreateNew();
// Set operation input from a source file.
FileRef sourceFileRef =
FileRef.CreateFromLocalFile(
@"compressPDFInput.pdf"
);
compressPDFOperation.SetInput(sourceFileRef);
// Execute the operation.
FileRef result = compressPDFOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory
.GetCurrentDirectory()
+ "/output/compressPDFOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext =
ExecutionContext.create(credentials);
CompressPDFOperation compressPDFOperation = CompressPDFOperation.createNew();
// Set operation input from a source file.
FileRef source =
FileRef.createFromLocalFile(
"src/main/resources/compressPDFInput.pdf
");
compressPDFOperation.setInput(source);
// Execute the operation
FileRef result = compressPDFOperation.execute(executionContext);
// Save the result at the specified location
result.saveAs("output/compressPDFOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
reorderPagesOperation = PDFServicesSdk.ReorderPages.Operation.createNew();
// Set operation input from a source file, along with specifying the order of the pages for rearranging the pages in a PDF file.
const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/reorderPagesInput.pdf');
const pageRanges = getPageRangeForReorder();
reorderPagesOperation.setInput(input);
reorderPagesOperation.setPagesOrder(pageRanges);
// Execute the operation and Save the result to the specified location.
reorderPagesOperation.execute(executionContext)
.then(result => result.saveAsFile('output/reorderPagesOutput.pdf'));
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
// Create a new operation instance
ReorderPagesOperation reorderPagesOperation = ReorderPagesOperation.CreateNew();
// Set operation input from a source file, along with specifying the order of the pages for rearranging the pages in a PDF file.
FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"reorderPagesInput.pdf");
reorderPagesOperation.SetInput(sourceFileRef);
PageRanges pageRanges = GetPageRangeForReorder();
reorderPagesOperation.SetPagesOrder(pageRanges);
// Execute the operation.
FileRef result = reorderPagesOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() +
"/output/reorderPagesOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
ReorderPagesOperation reorderPagesOperation = ReorderPagesOperation.createNew();
// Set operation input from a source file, along with specifying the order of the pages for rearranging the pages in a PDF file.
FileRef source =
FileRef.createFromLocalFile( "src/main/resources/reorderPagesInput.pdf" );
PageRanges pageRanges = getPageRangeForReorder();
reorderPagesOperation.setInput(source);
reorderPagesOperation.setPagesOrder(pageRanges);
// Execute the operation.
FileRef result = reorderPagesOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/reorderPagesOutput.pdf");
#Update this code sample in _includes/code-sample.html on line 868
// Update this code sample in _includes/code-sample.html on line 872
// Update this code sample in _includes/code-sample.html on line 876
curl --location --request POST 'https://cpf-ue1.adobe.io/ops/:create?respondWith=%7B%22reltype%22%3A%20%22http%3A%2F%2Fns.adobe.com%2Frel%2Fprimary%22%7D' \
--header 'Authorization: Bearer ' \
--header 'Accept: application/json, text/plain, */*' \
--header 'x-api-key: ' \
--header 'Prefer: respond-async,wait=0' \
--form 'contentAnalyzerRequests="{
\"cpf:inputs\": {
\"documentsIn\": [{
\"pageRanges\": {
\"cpf:inline\": [{
\"start\": 1,
\"end\": 4
}]
},
\"documentIn\": {
\"cpf:location\": \"InputFile0\",
\"dc:format\": \"application/pdf\"
}
}, {
\"pageRanges\": {
\"cpf:inline\": [{
\"start\": 1,
\"end\": 25
}]
},
\"documentIn\": {
\"cpf:location\": \"InputFile1\",
\"dc:format\": \"application/pdf\"
}
}, {
\"pageRanges\": {
\"cpf:inline\": [{
\"start\": 1
}, {
\"end\": 25
}, {
\"start\": 1,
\"end\": 25
}]
},
\"documentIn\": {
\"cpf:location\": \"InputFile2\",
\"dc:format\": \"application/pdf\"
}
}]
},
\"cpf:engine\": {
\"repo:assetId\": \"urn:aaid:cpf:Service-916ee91c156b42349a7847a7d564fb13\"
},
\"cpf:outputs\": {
\"documentOut\": {
\"cpf:location\": \"OutputFile\",
\"dc:format\": \"application/pdf\"
}
}
}"' \
--form 'InputFile0=@""' \
--form 'InputFile1=@""' \
--form 'InputFile2=@""'
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create( credentials ),
combineFilesOperation = PDFServicesSdk.CombineFiles.Operation.createNew();
// Set operation input from a source file.
const combineSource1 = PDFServicesSdk.FileRef.createFromLocalFile( 'resources/combineFilesInput1.pdf' ),
combineSource2 = PDFServicesSdk.FileRef.createFromLocalFile( 'resources/combineFilesInput2.pdf' );
combineFilesOperation.addInput( combineSource1 );
combineFilesOperation.addInput( combineSource2 );
// Execute the operation and Save the result to the specified location.
combineFilesOperation.execute( executionContext )
.then(result => result.saveAsFile( 'output/combineFilesOutput.pdf' ));
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.Create( credentials );
CombineFilesOperation combineFilesOperation = CombineFilesOperation.CreateNew();
// Add operation input from source files.
FileRef combineSource1 = FileRef
.CreateFromLocalFile( @"combineFilesInput1.pdf" );
FileRef combineSource2 = FileRef
.CreateFromLocalFile( @"combineFilesInput2.pdf" );
combineFilesOperation.AddInput( combineSource1 );
combineFilesOperation.AddInput( combineSource2 );
// Execute the operation.
FileRef result = combineFilesOperation.Execute( executionContext );
// Save the result to the specified location.
result.SaveAs( Directory.GetCurrentDirectory() +
"/output/combineFilesOutput.pdf" );
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
ReorderPagesOperation reorderPagesOperation = ReorderPagesOperation.createNew();
// Set operation input from a source file, along with specifying the order of the pages for rearranging the pages in a PDF file.
FileRef source =
FileRef.createFromLocalFile( "src/main/resources/reorderPagesInput.pdf" );
PageRanges pageRanges = getPageRangeForReorder();
reorderPagesOperation.setInput(source);
reorderPagesOperation.setPagesOrder(pageRanges);
// Execute the operation.
FileRef result = reorderPagesOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/reorderPagesOutput.pdf");
// Create an ExecutionContext using credentials
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);
// Create a new operation instance.
const splitPDFOperation = PDFServicesSdk.SplitPDF.Operation.createNew(),
input = PDFServicesSdk.FileRef.createFromLocalFile('resources/splitPDFInput.pdf',
PDFServicesSdk.SplitPDF.SupportedSourceFormat.pdf);
// Set operation input from a source file.
splitPDFOperation.setInput(input);
// Set the number of documents to split the input PDF file into.
splitPDFOperation.setFileCount(2);
// Execute the operation and Save the result to the specified location.
splitPDFOperation.execute(executionContext)
.then(result => {
let saveFilesPromises = [];
for(let i = 0; i < result.length; i++){
saveFilesPromises.push(result[i].saveAsFile(`output/splitPDFOutput_${i}.pdf`));
}
return Promise.all(saveFilesPromises);
});
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
// Create a new operation instance
SplitPDFOperation splitPDFOperation = SplitPDFOperation.CreateNew();
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"splitPDFInput.pdf");
splitPDFOperation.SetInput(sourceFileRef);
// Set the number of documents to split the input PDF file into.
splitPDFOperation.SetFileCount(2);
// Execute the operation.
List result = splitPDFOperation.Execute(executionContext);
// Save the result to the specified location.
int index = 0;
foreach (FileRef fileRef in result)
{
fileRef.SaveAs(Directory.GetCurrentDirectory() + "/output/splitPDFOutput_" +
index + ".pdf");
index++;
}
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
SplitPDFOperation splitPDFOperation = SplitPDFOperation.createNew();
// Set operation input from a source file.
FileRef source = FileRef.createFromLocalFile("src/main/resources/splitPDFInput.pdf");
splitPDFOperation.setInput(source);
// Set the number of documents to split the input PDF file into.
splitPDFOperation.setFileCount(2);
// Execute the operation.
List result = splitPDFOperation.execute(executionContext);
// Save the result to the specified location.
int index = 0;
for (FileRef fileRef : result) {
fileRef.saveAs("output/splitPDFOutput_" + index + ".pdf");
index++;
}
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
insertPagesOperation = PDFServicesSdk.InsertPages.Operation.createNew();
// Set operation base input from a source file.
const baseInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/baseInput.pdf');
insertPagesOperation.setBaseInput(baseInputFile);
// Create a FileRef instance using a local file.
const firstFileToInsert = PDFServicesSdk.FileRef.createFromLocalFile('resources/firstFileToInsertInput.pdf'),
pageRanges = getPageRangesForFirstFile();
// Adds the pages (specified by the page ranges)
// of the input PDF file to be
// inserted at the specified page of the base PDF file.
insertPagesOperation.addPagesToInsertAt(2, firstFileToInsert, pageRanges);
// Create a FileRef instance using a local file.
const secondFileToInsert = PDFServicesSdk.FileRef.createFromLocalFile('resources/secondFileToInsertInput.pdf');
// Adds all the pages of the input PDF file
// to be inserted at the specified
// page of the base PDF file.
insertPagesOperation.addPagesToInsertAt(3, secondFileToInsert);
// Execute the operation and Save the
// result to the specified location.
insertPagesOperation.execute(executionContext)
.then(result => result.saveAsFile('output/insertPagesOutput.pdf'))
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
// Create a new operation instance
InsertPagesOperation insertPagesOperation = InsertPagesOperation.CreateNew();
// Set operation base input from a source file.
FileRef baseSourceFile = FileRef.CreateFromLocalFile(@"baseInput.pdf");
insertPagesOperation.SetBaseInput(baseSourceFile);
// Create a FileRef instance using a local file.
FileRef firstFileToInsert =
FileRef.CreateFromLocalFile(
@"firstFileToInsertInput.pdf"
);
PageRanges pageRanges = GetPageRangeForFirstFile();
// Adds the pages (specified by the page ranges) of the input PDF file to be inserted at the specified page of the base PDF file.
insertPagesOperation.AddPagesToInsertAt(
firstFileToInsert, pageRanges, 2
);
// Create a FileRef instance using a local file.
FileRef secondFileToInsert = FileRef
.CreateFromLocalFile(
@"secondFileToInsertInput.pdf"
);
// Adds all the pages of the input PDF file to be inserted at the specified page of the base PDF file.
insertPagesOperation
.AddPagesToInsertAt(secondFileToInsert, 3);
// Execute the operation.
FileRef result = insertPagesOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory()
+ "/output/insertPagesOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
InsertPagesOperation insertPagesOperation = InsertPagesOperation.createNew();
// Set operation base input from a source file.
FileRef baseSourceFile = FileRef.createFromLocalFile(
"src/main/resources/baseInput.pdf"
);
insertPagesOperation.setBaseInput(baseSourceFile);
// Create a FileRef instance using a local file.
FileRef firstFileToInsert =
FileRef.createFromLocalFile(
"src/main/resources/firstFileToInsertInput.pdf"
);
PageRanges pageRanges =
getPageRangeForFirstFile ();
// Adds the pages (specified by the page ranges) of the input PDF file to be inserted at the specified page of the base PDF file.
insertPagesOperation
.addPagesToInsertAt(firstFileToInsert, pageRanges, 2);
// Create a FileRef instance using a local file.
FileRef secondFileToInsert = FileRef.createFromLocalFile(
"src/main/resources/secondFileToInsertInput.pdf"
);
// Adds all the pages of the input PDF file to be inserted at the specified page of the base PDF file.
insertPagesOperation
.addPagesToInsertAt(secondFileToInsert, 3);
// Execute the operation.
FileRef result = insertPagesOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/insertPagesOutput.pdf");
curl --location --request POST 'https://cpf-ue1.adobe.io/ops/:create?respondWith=%7B%22reltype%22%3A%20%22http%3A%2F%2Fns.adobe.com%2Frel%2Fprimary%22%7D' \
--header 'Authorization: Bearer ' \
--header 'Accept: application/json, text/plain, */*' \
--header 'x-api-key: ' \
--header 'Prefer: respond-async,wait=0' \
--form 'contentAnalyzerRequests="{
\"cpf:engine\":{
\"repo:assetId\":\"urn:aaid:cpf:Service-52d5db6097ed436ebb96f13a4c7bf8fb\"
},
\"cpf:inputs\":{
\"documentIn\":{
\"cpf:location\":\"InputFile0\",
\"dc:format\":\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"
},
\"params\":{
\"cpf:inline\":{
\"outputFormat\": \"pdf\",
\"jsonDataForMerge\": {
\"customerName\": \"Kane Miller\",
\"customerVisits\": 100,
\"itemsBought\": [
{
\"name\": \"Sprays\",
\"quantity\": 50,
\"amount\": 100
},
{
\"name\": \"Chemicals\",
\"quantity\": 100,
\"amount\": 200
}
],
\"totalAmount\": 300,
\"previousBalance\": 50,
\"lastThreeBillings\": [100, 200, 300],
\"photograph\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP88h8AAu0B9XNPCQQAAAAASUVORK5CYII=\"
}
}
}
},
\"cpf:outputs\":{
\"documentOut\":{
\"cpf:location\":\"OutputFile\",
\"dc:format\":\"application/pdf\"
}
}
}"' \
--form 'InputFile0=@""'
// Setup input data for the document merge process
const jsonString = fs.readFileSync('resources/salesOrder.json'),
jsonDataForMerge = JSON.parse(jsonString);
// Create an ExecutionContext using credentials
const executionContext = PDFToolsSdk.ExecutionContext.create(credentials);
// Create a new DocumentMerge options instance
const documentMerge = PDFToolsSdk.DocumentMerge,
documentMergeOptions = documentMerge.options,
options = new documentMergeOptions.DocumentMergeOptions(jsonDataForMerge, documentMergeOptions.OutputFormat.PDF);
// Create a new operation instance using the options instance
const documentMergeOperation = documentMerge.Operation.createNew(options)
// Set operation input document template from a source file.
const input = PDFToolsSdk.FileRef.createFromLocalFile('resources/salesOrderTemplate.docx');
documentMergeOperation.setInput(input);
// Execute the operation and Save the result to the specified location.
documentMergeOperation.execute(executionContext)
.then(result => result.saveAsFile('output/salesOrderOutput.pdf'))
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
// Setup input data for the document merge process
var content = File.ReadAllText(@"salesOrder.json");
JObject jsonDataForMerge = JObject.Parse(content);
// Create a new DocumentMerge Options instance
DocumentMergeOptions documentMergeOptions = new DocumentMergeOptions(jsonDataForMerge, OutputFormat.PDF);
// Create a new DocumentMerge Operation instance with the DocumentMerge Options instance
DocumentMergeOperation documentMergeOperation = DocumentMergeOperation.CreateNew(documentMergeOptions);
// Set the operation input document template from a source file.
documentMergeOperation.SetInput(FileRef.CreateFromLocalFile(@"salesOrderTemplate.docx"));
// Execute the operation.
FileRef result = documentMergeOperation.Execute(executionContext);
// Save the result to the specified location
result.SaveAs(Directory.GetCurrentDirectory() + "/output/salesOrderOutput.pdf");
// Setup input data for the document merge process
String content = new String(Files.readAllBytes(Paths.get("src/main/resources/salesOrder.json")));
JSONObject jsonDataForMerge = new JSONObject(content);
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.create(credentials);
//Create a new DocumentMergeOptions instance
DocumentMergeOptions documentMergeOptions = new DocumentMergeOptions(jsonDataForMerge, OutputFormat.PDF);
// Create a new DocumentMergeOperation instance with the DocumentMergeOptions instance
DocumentMergeOperation documentMergeOperation = DocumentMergeOperation.createNew(documentMergeOptions);
// Set the operation input document template from a source file.
FileRef documentTemplate = FileRef.createFromLocalFile("src/main/resources/salesOrderTemplate.docx");
documentMergeOperation.setInput(documentTemplate);
// Execute the operation
FileRef result = documentMergeOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/salesOrderOutput.pdf");
// Create an ExecutionContext using credentials
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);
// Create new permissions instance and add the required permissions
const protectPDF = PDFServicesSdk.ProtectPDF,
protectPDFOptions = protectPDF.options,
permissions = protectPDFOptions.Permissions.createNew();
permissions.addPermission(protectPDFOptions.Permission.PRINT_LOW_QUALITY);
permissions.addPermission(protectPDFOptions.Permission.EDIT_DOCUMENT_ASSEMBLY);
permissions.addPermission(protectPDFOptions.Permission.COPY_CONTENT);
// Build ProtectPDF options by setting a User as well as an Owner/Permissions Password, Permissions,
// Encryption Algorithm (used for encrypting the PDF file) and specifying the type of content to encrypt.
const options = new protectPDFOptions.PasswordProtectOptions.Builder()
.setUserPassword("openpassword")
.setOwnerPassword("permissionspassword")
.setPermissions(permissions)
.setEncryptionAlgorithm(protectPDFOptions.EncryptionAlgorithm.AES_256)
.setContentEncryption(protectPDFOptions.ContentEncryption.ALL_CONTENT_EXCEPT_METADATA)
.build();
// Create a new operation instance.
const protectPDFOperation = protectPDF.Operation.createNew(options);
// Set operation input from a source file.
const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/protectPDFInput.pdf');
protectPDFOperation.setInput(input);
// Execute the operation and Save the result to the specified location.
protectPDFOperation.execute(executionContext)
.then(result => result.saveAsFile('output/protectPDFOutput.pdf'))
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
// Create new permissions instance and add the required permissions
Permissions permissions = Permissions.CreateNew();
permissions.AddPermission(Permission.PRINT_LOW_QUALITY);
permissions.AddPermission(Permission.EDIT_DOCUMENT_ASSEMBLY);
permissions.AddPermission(Permission.COPY_CONTENT);
// Build ProtectPDF options by setting a User as well as Owner/Permissions Password, Permissions,
// Encryption Algorithm (used for encrypting the PDF file) and specifying the type of content to encrypt.
ProtectPDFOptions protectPDFOptions = ProtectPDFOptions.PasswordProtectOptionsBuilder()
.SetUserPassword("openpassword")
.SetOwnerPassword("permissionspassword")
.SetPermissions(permissions)
.SetEncryptionAlgorithm(EncryptionAlgorithm.AES_256)
.SetContentEncryption(ContentEncryption.ALL_CONTENT_EXCEPT_METADATA)
.Build();
// Create a new operation instance
ProtectPDFOperation protectPDFOperation = ProtectPDFOperation.CreateNew(protectPDFOptions);
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"protectPDFInput.pdf");
protectPDFOperation.SetInput(sourceFileRef);
// Execute the operation.
FileRef result = protectPDFOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() + "/output/protectPDFOutput.pdf");
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.create(credentials);
// Create new permissions instance and add the required permissions
Permissions permissions = Permissions.createNew();
permissions.addPermission(Permission.PRINT_LOW_QUALITY);
permissions.addPermission(Permission.EDIT_DOCUMENT_ASSEMBLY);
permissions.addPermission(Permission.COPY_CONTENT);
// Build ProtectPDF options by setting a User as well as Owner/Permissions Password, Permissions,
// Encryption Algorithm (used for encrypting the PDF file) and specifying the type of content to encrypt.
ProtectPDFOptions protectPDFOptions = ProtectPDFOptions.passwordProtectOptionsBuilder()
.setOwnerPassword("openpassword")
.setUserPassword("permissionspassword")
.setPermissions(permissions)
.setEncryptionAlgorithm(EncryptionAlgorithm.AES_256)
.setContentEncryption(ContentEncryption.ALL_CONTENT_EXCEPT_METADATA)
.build();
// Create a new operation instance.
ProtectPDFOperation protectPDFOperation = ProtectPDFOperation.createNew(protectPDFOptions);
// Set operation input from a source file.
FileRef source = FileRef.createFromLocalFile("src/main/resources/protectPDFInput.pdf");
protectPDFOperation.setInput(source);
// Execute the operation
FileRef result = protectPDFOperation.execute(executionContext);
// Save the result at the specified location
result.saveAs("output/protectPDFOutput.pdf");
// Create an ExecutionContext using credentials
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);
// Create a new operation instance.
const removeProtectionOperation = PDFServicesSdk.RemoveProtection.Operation.createNew(),
input = PDFServicesSdk.FileRef.createFromLocalFile(
'resources/removeProtectionInput.pdf',
PDFServicesSdk.RemoveProtection.SupportedSourceFormat.pdf);
// Set operation input from a source file.
removeProtectionOperation.setInput(input);
// Set the password for removing security from a PDF document.
removeProtectionOperation.setPassword("password");
// Execute the operation and Save the result to the specified location.
removeProtectionOperation.execute(executionContext)
.then(result => result.saveAsFile('output/removeProtectionOutput.pdf'))
// Create an ExecutionContext using credentials.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
// Create a new operation instance
RemoveProtectionOperation removeProtectionOperation = RemoveProtectionOperation.CreateNew();
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"removeProtectionInput.pdf");
removeProtectionOperation.SetInput(sourceFileRef);
// Set the password for removing security from a PDF document.
removeProtectionOperation.SetPassword("password");
// Execute the operation.
FileRef result = removeProtectionOperation.Execute(executionContext);
// Save the result to the specified location.
result.SaveAs(Directory.GetCurrentDirectory() +
"/output/removeProtectionOutput.pdf");
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
RemoveProtectionOperation removeProtectionOperation = RemoveProtectionOperation.createNew();
// Set operation input from a source file.
FileRef source = FileRef.createFromLocalFile("src/main/resources/removeProtectionInput.pdf");
removeProtectionOperation.setInput(source);
// Set the password for removing security from a PDF document.
removeProtectionOperation.setPassword("password");
// Execute the operation.
FileRef result = removeProtectionOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/removeProtectionOutput.pdf");
const credentials = PDFServicesSdk.Credentials
.serviceAccountCredentialsBuilder()
.fromFile("pdfservices-api-credentials.json")
.build();
// Create an ExecutionContext using credentials and create a new operation instance.
const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
pdfPropertiesOperation = PDFServicesSdk.PDFProperties.Operation.createNew();
// Set operation input from a source file.
const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/pdfPropertiesInput.pdf');
pdfPropertiesOperation.setInput(input);
// Provide any custom configuration options for the operation.
const options = new PDFServicesSdk.PDFProperties.options.PDFPropertiesOptions.Builder()
.includePageLevelProperties(true)
.build();
pdfPropertiesOperation.setOptions(options);
// Execute the operation and log the JSON Object.
pdfPropertiesOperation.execute(executionContext)
.then(result => console.log("The resultant json object is : " + JSON.stringify(result)))
// Initial setup, create credentials instance
Credentials credentials = Credentials.ServiceAccountCredentialsBuilder()
.FromFile(Directory.GetCurrentDirectory() + "/pdfservices-api-credentials.json")
.Build();
// Create an ExecutionContext using credentials and create a new operation instance
ExecutionContext executionContext = ExecutionContext.Create(credentials);
PDFPropertiesOperation pdfPropertiesOperation = PDFPropertiesOperation.CreateNew();
// Provide an input FileRef for the operation
FileRef source = FileRef.CreateFromLocalFile(@"pdfPropertiesInput.pdf");
pdfPropertiesOperation.SetInput(source);
// Build PDF Properties options to include page level properties and set them into the operation
PDFPropertiesOptions pdfPropertiesOptions = PDFPropertiesOptions.PDFPropertiesOptionsBuilder()
.IncludePageLevelProperties(true)
.Build();
pdfPropertiesOperation.SetOptions(pdfPropertiesOptions);
// Execute the operation and return JSON Object
JObject result = pdfPropertiesOperation.Execute(executionContext);
// Initial setup, create credentials instance.
Credentials credentials = Credentials.serviceAccountCredentialsBuilder()
.fromFile("pdfservices-api-credentials.json")
.build();
//Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
PDFPropertiesOperation pdfPropertiesOperation = PDFPropertiesOperation.createNew();
// Provide an input FileRef for the operation
FileRef source = FileRef.createFromLocalFile("src/main/resources/pdfPropertiesInput.pdf");
pdfPropertiesOperation.setInputFile(source);
// Build PDF Properties options to include page level properties and set them into the operation
PDFPropertiesOptions pdfPropertiesOptions = PDFPropertiesOptions.PDFPropertiesOptionsBuilder()
.includePageLevelProperties(true)
.build();
pdfPropertiesOperation.setOptions(pdfPropertiesOptions);
// Execute the operation and return JSON Object
JSONObject result = pdfPropertiesOperation.execute(executionContext);
<div id="adobe-dc-view" style="height: 360px; width: 500px;"></div>
<script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
<script type="text/javascript">
document.addEventListener("adobe_dc_view_sdk.ready", function(){
var adobeDCView = new AdobeDC.View({clientId: "<YOUR_CLIENT_ID>", divId: "adobe-dc-view"});
adobeDCView.previewFile({
content:{ location:
{ url: "https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea%20Brochure.pdf"}},
metaData:{fileName: "Bodea Brochure.pdf"}
},
{
embedMode: "SIZED_CONTAINER"
});
});
</script>
document.addEventListener("adobe_dc_view_sdk.ready", function() {
var adobeDCView = new AdobeDC.View({clientId: "<YOUR_CLIENT_ID>", divId: "adobe-dc-view"});
adobeDCView.previewFile({
content: {location: {url: "(path to your PDF)/yourfilename.pdf"}},
metaData: {fileName: "yourfilename.pdf"}
},
{showAnnotationTools: true});
});
adobeDCView.registerCallback(
/* Type of call back */
AdobeDC.View.Enum.CallbackType.EVENT_LISTENER,
/* call back function */
function(event) {
console.log(event);
},
{ enablePDFAnalytics: true }
);
const profile = {
userProfile: {
name: '',
firstName: '',
lastName: '',
email: ''
}
};
adobeDCView.registerCallback(
AdobeDC.View.Enum.CallbackType.GET_USER_PROFILE_API,
function() {
return new Promise((resolve, reject) => {
resolve({
code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
data: profile
});
});
}
);
const saveOptions = {
autoSaveFrequency: <Number, default=0>,
enableFocusPolling: <Boolean, default=false>,
showSaveButton: <Boolean, default=true>
}
adobeDCView.registerCallback(
AdobeDC.View.Enum.CallbackType.SAVE_API,
function(metadata, content, options) {
return new Promise((resolve, reject) => {
resolve({
code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
data: {
metaData: <File MetaData>
}
});
});
},
saveOptions);
<div id="adobe-dc-view"></div>
<script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
<script type="text/javascript">
document.addEventListener("adobe_dc_view_sdk.ready", function () {
var adobeDCView = new AdobeDC.View({clientId: "<YOUR_CLIENT_ID>", divId: "adobe-dc-view"});
adobeDCView.previewFile({
content:{location: {url: "https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf"}},
metaData:{fileName: "Bodea Brochure.pdf"}
}, {"showLeftHandPanel": true, "showPageControls": false});
});
</script>
Start Embedding PDFs in Minutes
Start your free 6-month trial today with 1,000 PDF transactions
-
Obtain free credentials
-
Copy JavaScript code or download samples for React and Angular
-
Add credentials to your code and run!
Integrations

Adobe Experience Manager
Adobe Experience Manager customers can easily drag and drop a high-fidelity PDF viewer directly into web applications without the need for additional code or customizations. Includes pre-configurable settings for comments, printing, downloading, and integrated Adobe Analytics.

Adobe Analytics
Out of the box Adobe Analytics integration allows customers to seamlessly enable rich analytics and gain insights on end user experience. Extend functionality with chatbots or calls to action based on user interactions.
Use Cases for PDF Embed API
Student Teacher Collaboration
Accelerate digital learning programs with embedded PDF viewing for teacher and peer document collaboration.
Reviews and Approvals
Maximize remote worker productivity with multi-user document collaboration including commenting, markup, text edits, and more.
Digital Content Publishing
Publish whitepapers and marketing content with end-user interactivity, security controls, and analytics.
Report Creation and Editing
Create and embed reports for internal or external consumption, sharing, and review.