Skip to content

Commit 398c14b

Browse files
committed
Updates for SDK 3.0.0
1 parent 032cddb commit 398c14b

11 files changed

Lines changed: 1054 additions & 1015 deletions

File tree

README.md

Lines changed: 799 additions & 808 deletions
Large diffs are not rendered by default.
Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
/**
2-
* This sample illustrates how to export a PDF file to a Word (DOCX) file
3-
*
4-
* Refer to README.md for instructions on how to run the samples.
5-
*/
6-
component displayname="Export PDF To DOCX" {
7-
public ExportPDFToDOCX function init() {
8-
variables.java_Credentials = createObject("java", "com.adobe.pdfservices.operation.auth.Credentials");
9-
variables.java_ExecutionContext = createObject("java", "com.adobe.pdfservices.operation.ExecutionContext");
10-
variables.java_ExportPDFOperation = createObject("java", "com.adobe.pdfservices.operation.pdfops.ExportPDFOperation");
11-
variables.java_ExportPDFTargetFormat = createObject("java", "com.adobe.pdfservices.operation.pdfops.options.exportpdf.ExportPDFTargetFormat");
12-
variables.java_FileRef = createObject("java", "com.adobe.pdfservices.operation.io.FileRef");
13-
14-
return this;
15-
}
16-
17-
public void function run() {
18-
try {
19-
// Initial setup, create credentials instance.
20-
var credentials = Credentials.serviceAccountCredentialsBuilder()
21-
.fromFile(application.credentialsJSONFile)
22-
.build();
23-
24-
// Create an ExecutionContext using credentials and create a new operation instance.
25-
var executionContext = variables.java_ExecutionContext.create(credentials);
26-
var exportPdfOperation = variables.java_ExportPDFOperation.createNew(
27-
variables.java_ExportPDFTargetFormat.DOCX
28-
);
29-
30-
// Set operation input from a local PDF file
31-
var sourceFileRef = variables.java_FileRef.createFromLocalFile(
32-
application.resourcesPath & "/exportPDFInput.pdf"
33-
);
34-
exportPdfOperation.setInput(sourceFileRef);
35-
36-
// Execute the operation.
37-
var result = exportPdfOperation.execute(executionContext);
38-
39-
// Save the result to the specified location.
40-
result.saveAs(application.outputPath & "/exportPdfOutput.docx");
41-
}
42-
catch(any e) {
43-
writeLog("Exception encountered while executing operation: #e.message#");
44-
}
45-
}
46-
}
1+
/**
2+
* This sample illustrates how to export a PDF file to a Word (DOCX) file
3+
*
4+
* Refer to README.md for instructions on how to run the samples.
5+
*/
6+
component displayname="Export PDF To DOCX" {
7+
public ExportPDFToDOCX function init() {
8+
variables.java_Credentials = createObject("java", "com.adobe.pdfservices.operation.auth.Credentials");
9+
variables.java_ExecutionContext = createObject("java", "com.adobe.pdfservices.operation.ExecutionContext");
10+
variables.java_ExportPDFOperation = createObject("java", "com.adobe.pdfservices.operation.pdfops.ExportPDFOperation");
11+
variables.java_ExportPDFTargetFormat = createObject("java", "com.adobe.pdfservices.operation.pdfops.options.exportpdf.ExportPDFTargetFormat");
12+
variables.java_FileRef = createObject("java", "com.adobe.pdfservices.operation.io.FileRef");
13+
14+
return this;
15+
}
16+
17+
public void function run() {
18+
try {
19+
// Initial setup, create credentials instance.
20+
var credentials = variables.java_Credentials.serviceAccountCredentialsBuilder()
21+
.fromFile(application.credentialsJSONFile)
22+
.build();
23+
24+
// Create an ExecutionContext using credentials and create a new operation instance.
25+
var executionContext = variables.java_ExecutionContext.create(credentials);
26+
var exportPdfOperation = variables.java_ExportPDFOperation.createNew(
27+
variables.java_ExportPDFTargetFormat.DOCX
28+
);
29+
30+
// Set operation input from a local PDF file
31+
var sourceFileRef = variables.java_FileRef.createFromLocalFile(
32+
application.resourcesPath & "/exportPDFInput.pdf"
33+
);
34+
exportPdfOperation.setInput(sourceFileRef);
35+
36+
// Execute the operation.
37+
var result = exportPdfOperation.execute(executionContext);
38+
39+
// Save the result to the specified location.
40+
result.saveAs(application.outputPath & "/exportPdfOutput.docx");
41+
}
42+
catch(any e) {
43+
writeLog("Exception encountered while executing operation: #e.message#");
44+
}
45+
}
46+
}

components/exportpdf/ExportPDFToJPEG.cfc renamed to components/exportpdf/ExportPDFToDOCXWithOCROption.cfc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
2-
* This sample illustrates how to export a PDF file to JPEG.
3-
*
4-
* Note that exporting a PDF file to an image format results in a ZIP archive containing one image per page.
2+
* This sample illustrates how to export a PDF file to a Word (DOCX) file. The OCR processing is also performed on the input PDF file to extract text from images in the document.
53
*
64
* Refer to README.md for instructions on how to run the samples.
75
*/
8-
component displayname="Export PDF To JPEG" {
9-
public ExportPDFToJPEG function init() {
6+
component displayname="Export PDF To DOCX With OCR Option" {
7+
public ExportPDFToDOCXWithOCROption function init() {
108
variables.java_Credentials = createObject("java", "com.adobe.pdfservices.operation.auth.Credentials");
119
variables.java_ExecutionContext = createObject("java", "com.adobe.pdfservices.operation.ExecutionContext");
1210
variables.java_ExportPDFOperation = createObject("java", "com.adobe.pdfservices.operation.pdfops.ExportPDFOperation");
11+
variables.java_ExportOCRLocale = createObject("java", "com.adobe.pdfservices.operation.pdfops.options.exportpdf.ExportOCRLocale");
12+
variables.java_ExportPDFOptions = createObject("java", "com.adobe.pdfservices.operation.pdfops.options.exportpdf.ExportPDFOptions");
1313
variables.java_ExportPDFTargetFormat = createObject("java", "com.adobe.pdfservices.operation.pdfops.options.exportpdf.ExportPDFTargetFormat");
1414
variables.java_FileRef = createObject("java", "com.adobe.pdfservices.operation.io.FileRef");
1515

@@ -26,20 +26,24 @@ component displayname="Export PDF To JPEG" {
2626
// Create an ExecutionContext using credentials and create a new operation instance.
2727
var executionContext = variables.java_ExecutionContext.create(credentials);
2828
var exportPdfOperation = variables.java_ExportPDFOperation.createNew(
29-
variables.java_ExportPDFTargetFormat.JPEG
29+
variables.java_ExportPDFTargetFormat.DOCX
3030
);
3131

32-
// Set operation input from a source file.
32+
// Set operation input from a local PDF file
3333
var sourceFileRef = variables.java_FileRef.createFromLocalFile(
34-
application.resourcesPath & "/exportPDFToImageInput.pdf"
34+
application.resourcesPath & "/exportPDFInput.pdf"
3535
);
3636
exportPdfOperation.setInput(sourceFileRef);
3737

38+
// Create a new ExportPDFOptions instance from the specified OCR locale and set it into the operation.
39+
var exportPDFOptions = variables.java_ExportPDFOptions.init(variables.java_ExportOCRLocale.EN_US);
40+
exportPDFOperation.setOptions(exportPDFOptions);
41+
3842
// Execute the operation.
3943
var result = exportPdfOperation.execute(executionContext);
4044

4145
// Save the result to the specified location.
42-
result.saveAs(application.outputPath & "/exportPDFToJPEG.zip");
46+
result.saveAs(application.outputPath & "/exportPDFWithOCROptionsOutput.docx");
4347
}
4448
catch(any e) {
4549
writeLog("Exception encountered while executing operation: #e.message#");
Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
/**
2-
* This sample illustrates how to export a PDF file to a list of JPEG files.
3-
*
4-
* Refer to README.md for instructions on how to run the samples.
5-
*/
6-
component displayname="Export PDF To JPEG List" {
7-
public ExportPDFToJPEGList function init() {
8-
variables.java_Credentials = createObject("java", "com.adobe.pdfservices.operation.auth.Credentials");
9-
variables.java_ExecutionContext = createObject("java", "com.adobe.pdfservices.operation.ExecutionContext");
10-
variables.java_CreatePDFOperation = createObject("java", "com.adobe.pdfservices.operation.pdfops.CreatePDFOperation");
11-
variables.java_FileRef = createObject("java", "com.adobe.pdfservices.operation.io.FileRef");
12-
variables.java_ExportPDFToImagesOperation = createObject("java", "com.adobe.pdfservices.operation.pdfops.ExportPDFToImagesOperation");
13-
variables.java_ExportPDFToImagesTargetFormat = createObject("java", "com.adobe.pdfservices.operation.pdfops.options.exportpdftoimages.ExportPDFToImagesTargetFormat");
14-
15-
return this;
16-
}
17-
18-
public void function run() {
19-
try {
20-
// Initial setup, create credentials instance.
21-
var credentials = java_Credentials.serviceAccountCredentialsBuilder()
22-
.fromFile(application.credentialsJSONFile)
23-
.build();
24-
25-
// Create an ExecutionContext using credentials and create a new operation instance.
26-
var executionContext = variables.java_ExecutionContext.create(credentials);
27-
var exportPDFToImagesOperation = variables.java_ExportPDFToImagesOperation.createNew(
28-
variables.java_ExportPDFToImagesTargetFormat.JPEG
29-
);
30-
31-
// Set operation input from a source file.
32-
var sourceFileRef = variables.java_FileRef.createFromLocalFile(
33-
application.resourcesPath & "/exportPDFToImageInput.pdf"
34-
);
35-
exportPDFToImagesOperation.setInput(sourceFileRef);
36-
37-
// Execute the operation.
38-
var results = exportPDFToImagesOperation.execute(executionContext);
39-
40-
// Save the result to the specified location.
41-
var index = 0;
42-
for (var result in results) {
43-
result.saveAs(application.outputPath & "/exportPDFToImagesOutput_" & index & ".jpeg");
44-
index++;
45-
}
46-
}
47-
catch(any e) {
48-
writeLog("Exception encountered while executing operation: #e.message#");
49-
}
50-
}
51-
}
1+
/**
2+
* This sample illustrates how to export a PDF file to a list of JPEG files.
3+
*
4+
* Refer to README.md for instructions on how to run the samples.
5+
*/
6+
component displayname="Export PDF To JPEG" {
7+
public ExportPDFToJPEG function init() {
8+
variables.java_Credentials = createObject("java", "com.adobe.pdfservices.operation.auth.Credentials");
9+
variables.java_ExecutionContext = createObject("java", "com.adobe.pdfservices.operation.ExecutionContext");
10+
variables.java_CreatePDFOperation = createObject("java", "com.adobe.pdfservices.operation.pdfops.CreatePDFOperation");
11+
variables.java_FileRef = createObject("java", "com.adobe.pdfservices.operation.io.FileRef");
12+
variables.java_ExportPDFToImagesOperation = createObject("java", "com.adobe.pdfservices.operation.pdfops.ExportPDFToImagesOperation");
13+
variables.java_ExportPDFToImagesTargetFormat = createObject("java", "com.adobe.pdfservices.operation.pdfops.options.exportpdftoimages.ExportPDFToImagesTargetFormat");
14+
15+
return this;
16+
}
17+
18+
public void function run() {
19+
try {
20+
// Initial setup, create credentials instance.
21+
var credentials = java_Credentials.serviceAccountCredentialsBuilder()
22+
.fromFile(application.credentialsJSONFile)
23+
.build();
24+
25+
// Create an ExecutionContext using credentials and create a new operation instance.
26+
var executionContext = variables.java_ExecutionContext.create(credentials);
27+
var exportPDFToImagesOperation = variables.java_ExportPDFToImagesOperation.createNew(
28+
variables.java_ExportPDFToImagesTargetFormat.JPEG
29+
);
30+
31+
// Set operation input from a source file.
32+
var sourceFileRef = variables.java_FileRef.createFromLocalFile(
33+
application.resourcesPath & "/exportPDFToImageInput.pdf"
34+
);
35+
exportPDFToImagesOperation.setInput(sourceFileRef);
36+
37+
// Execute the operation.
38+
var results = exportPDFToImagesOperation.execute(executionContext);
39+
40+
// Save the result to the specified location.
41+
var index = 0;
42+
for (var result in results) {
43+
result.saveAs(application.outputPath & "/exportPDFToJPEGOutput_" & index & ".jpeg");
44+
index++;
45+
}
46+
}
47+
catch(any e) {
48+
writeLog("Exception encountered while executing operation: #e.message#");
49+
}
50+
}
51+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* This sample illustrates how to export a PDF file to JPEG.
3+
*
4+
* The resulting file is a ZIP archive containing one image per page of the source PDF file
5+
*
6+
* Refer to README.md for instructions on how to run the samples.
7+
*/
8+
component displayname="Export PDF To JPEG Zip" {
9+
public ExportPDFToJPEGZip function init() {
10+
variables.java_Credentials = createObject("java", "com.adobe.pdfservices.operation.auth.Credentials");
11+
variables.java_ExecutionContext = createObject("java", "com.adobe.pdfservices.operation.ExecutionContext");
12+
variables.java_ExportPDFToImagesOperation = createObject("java", "com.adobe.pdfservices.operation.pdfops.ExportPDFToImagesOperation");
13+
variables.java_ExportPDFToImagesTargetFormat = createObject("java", "com.adobe.pdfservices.operation.pdfops.options.exportpdftoimages.ExportPDFToImagesTargetFormat");
14+
variables.java_OutputType = createObject("java", "com.adobe.pdfservices.operation.pdfops.options.exportpdftoimages.OutputType");
15+
variables.java_FileRef = createObject("java", "com.adobe.pdfservices.operation.io.FileRef");
16+
17+
return this;
18+
}
19+
20+
public void function run() {
21+
try {
22+
// Initial setup, create credentials instance.
23+
var credentials = variables.java_Credentials.serviceAccountCredentialsBuilder()
24+
.fromFile(application.credentialsJSONFile)
25+
.build();
26+
27+
// Create an ExecutionContext using credentials and create a new operation instance.
28+
var executionContext = variables.java_ExecutionContext.create(credentials);
29+
var exportPDFToImagesOperation = variables.java_ExportPDFToImagesOperation.createNew(
30+
variables.java_ExportPDFToImagesTargetFormat.JPEG
31+
);
32+
33+
// Set operation input from a source file.
34+
var sourceFileRef = variables.java_FileRef.createFromLocalFile(
35+
application.resourcesPath & "/exportPDFToImageInput.pdf"
36+
);
37+
exportPDFToImagesOperation.setInput(sourceFileRef);
38+
39+
// Set the output type to create zip of images.
40+
exportPDFToImagesOperation.setOutputType(variables.java_OutputType.ZIP_OF_PAGE_IMAGES);
41+
42+
// Execute the operation.
43+
var results = exportPDFToImagesOperation.execute(executionContext);
44+
45+
writeLog("Media type of the received asset is " & results.get(0).getMediaType());
46+
47+
// Save the result to the specified location.
48+
results.get(0).saveAs(application.outputPath & "/exportPDFToJPEGOutput.zip");
49+
}
50+
catch(any e) {
51+
writeLog("Exception encountered while executing operation: #e.message#");
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)