Convert a PDF file to other formats
Convert existing PDFs to popular formats, such as Microsoft Word, Excel, and PowerPoint, as well as text and image
Support for PDF to DOC, PDF to DOCX, PDF to JPEG, PDF to PNG, PDF to PPTX, PDF to RTF, PDF to XLSX
See our public API Reference and quickly try our APIs using the Postman collections
REST API
Node js
.Net
Java
Python
Copied to your clipboard// Please refer our Rest API docs for more information// https://developer.adobe.com/document-services/docs/apis/#tag/Export-PDFcurl --location --request POST 'https://pdf-services.adobe.io/operation/exportpdf' \--header 'x-api-key: {{Placeholder for client_id}}' \--header 'Content-Type: application/json' \--header 'Authorization: Bearer {{Placeholder for token}}' \--data-raw '{"assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718","targetFormat": "docx"}'// Legacy API can be found here// https://documentcloud.adobe.com/document-services/index.html#post-exportPDF
Copied to your clipboard// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample// Run the sample:// node src/exportpdftoimages/export-pdf-to-jpeg.jsconst {ServicePrincipalCredentials,PDFServices,MimeType,ExportPDFToImagesJob,ExportPDFToImagesTargetFormat,ExportPDFToImagesOutputType,ExportPDFToImagesParams,ExportPDFToImagesResult,SDKError,ServiceUsageError,ServiceApiError} = require("@adobe/pdfservices-node-sdk");const fs = require("fs");(async () => {let readStream;try {// Initial setup, create credentials instanceconst credentials = new ServicePrincipalCredentials({clientId: process.env.PDF_SERVICES_CLIENT_ID,clientSecret: process.env.PDF_SERVICES_CLIENT_SECRET});// Creates a PDF Services instanceconst pdfServices = new PDFServices({credentials});// Creates an asset(s) from source file(s) and uploadreadStream = fs.createReadStream("./exportPDFToImageInput.pdf");const inputAsset = await pdfServices.upload({readStream,mimeType: MimeType.PDF});// Create parameters for the jobconst params = new ExportPDFToImagesParams({targetFormat: ExportPDFToImagesTargetFormat.JPEG,outputType: ExportPDFToImagesOutputType.LIST_OF_PAGE_IMAGES});// Creates a new job instanceconst job = new ExportPDFToImagesJob({inputAsset,params});// Submit the job and get the job resultconst pollingURL = await pdfServices.submit({job});const pdfServicesResponse = await pdfServices.getJobResult({pollingURL,resultType: ExportPDFToImagesResult});// Get content from the resulting asset(s)const resultAssets = pdfServicesResponse.result.assets;for (let i = 0; i < resultAssets.length; i++) {const _outputFilePath = "./exportPDFToImageOutput_${i}.jpeg";console.log(`Saving asset at ${_outputFilePath}`);const streamAsset = await pdfServices.getContent({asset: resultAssets[i]});// Creates an output stream and copy stream asset's content to itconst outputStream = fs.createWriteStream(_outputFilePath);streamAsset.readStream.pipe(outputStream);}} catch (err) {if (err instanceof SDKError || err instanceof ServiceUsageError || err instanceof ServiceApiError) {console.log("Exception encountered while executing operation", err);} else {console.log("Exception encountered while executing operation", err);}} finally {readStream?.destroy();}})();
Copied to your clipboard// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples// Run the sample:// cd ExportPDFToDocx/// dotnet run ExportPDFToDocx.csprojnamespace ExportPDFToDocx{class Program{private static readonly ILog log = LogManager.GetLogger(typeof(Program));static void Main(){//Configure the loggingConfigureLogging();try{// Initial setup, create credentials instanceICredentials credentials = new ServicePrincipalCredentials(Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_ID"),Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_SECRET"));// Creates a PDF Services instancePDFServices pdfServices = new PDFServices(credentials);// Creates an asset from source file and uploadusing Stream inputStream = File.OpenRead(@"exportPdfInput.pdf");IAsset asset = pdfServices.Upload(inputStream, PDFServicesMediaType.PDF.GetMIMETypeValue());// Create parameters for the jobExportPDFParams exportPDFParams = ExportPDFParams.ExportPDFParamsBuilder(ExportPDFTargetFormat.DOCX).Build();// Creates a new job instanceExportPDFJob exportPDFJob = new ExportPDFJob(asset, exportPDFParams);// Submits the job and gets the job resultString location = pdfServices.Submit(exportPDFJob);PDFServicesResponse<ExportPDFResult> pdfServicesResponse =pdfServices.GetJobResult<ExportPDFResult>(location, typeof(ExportPDFResult));// Get content from the resulting asset(s)IAsset resultAsset = pdfServicesResponse.Result.Asset;StreamAsset streamAsset = pdfServices.GetContent(resultAsset);// Creating output streams and copying stream asset's content to itStream outputStream = File.OpenWrite(Directory.GetCurrentDirectory() + "/output/exportPdfOutput.docx");streamAsset.Stream.CopyTo(outputStream);outputStream.Close();}catch (ServiceUsageException ex){log.Error("Exception encountered while executing operation", ex);}catch (ServiceApiException ex){log.Error("Exception encountered while executing operation", ex);}catch (SDKException ex){log.Error("Exception encountered while executing operation", ex);}catch (IOException ex){log.Error("Exception encountered while executing operation", ex);}catch (Exception ex){log.Error("Exception encountered while executing operation", ex);}}static void ConfigureLogging(){ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));}}}
Copied to your clipboard// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples// Run the sample:// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.exportpdf.ExportPDFToDOCXpublic class ExportPDFToDOCX {// Initialize the logger.private static final Logger LOGGER = LoggerFactory.getLogger(ExportPDFToDOCX.class);public static void main(String[] args) {try (InputStream inputStream = Files.newInputStream(new File("src/main/resources/exportPDFInput.pdf").toPath())) {// Initial setup, create credentials instanceCredentials credentials = new ServicePrincipalCredentials(System.getenv("PDF_SERVICES_CLIENT_ID"),System.getenv("PDF_SERVICES_CLIENT_SECRET"));// Creates a PDF Services instancePDFServices pdfServices = new PDFServices(credentials);// Creates an asset(s) from source file(s) and uploadAsset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());// Create parameters for the jobExportPDFParams exportPDFParams = ExportPDFParams.exportPDFParamsBuilder(ExportPDFTargetFormat.DOCX).build();// Creates a new job instanceExportPDFJob exportPDFJob = new ExportPDFJob(asset, exportPDFParams);// Submit the job and gets the job resultString location = pdfServices.submit(exportPDFJob);PDFServicesResponse<ExportPDFResult> pdfServicesResponse = pdfServices.getJobResult(location, ExportPDFResult.class);// Get content from the resulting asset(s)Asset resultAsset = pdfServicesResponse.getResult().getAsset();StreamAsset streamAsset = pdfServices.getContent(resultAsset);// Creates an output stream and copy stream asset's content to itFiles.createDirectories(Paths.get("output/"));OutputStream outputStream = Files.newOutputStream(new File("output/exportPdfOutput.docx").toPath());LOGGER.info("Saving asset at output/exportPdfOutput.docx");IOUtils.copy(streamAsset.getInputStream(), outputStream);} catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {LOGGER.error("Exception encountered while executing operation", ex);}}}
Copied to your clipboard# Get the samples https://github.com/adobe/pdfservices-python-sdk-samples# Run the sample:# python python src/exportpdftoimages/export_pdf_to_jpeg.py# Initialize the loggerlogging.basicConfig(level=logging.INFO)class ExportPDFToDOCX:def __init__(self):try:file = open("./exportPDFToImageInput.pdf", "rb")input_stream = file.read()file.close()# Initial setup, create credentials instancecredentials = ServicePrincipalCredentials(client_id=os.getenv("PDF_SERVICES_CLIENT_ID"),client_secret=os.getenv("PDF_SERVICES_CLIENT_SECRET"),)# Creates a PDF Services instancepdf_services = PDFServices(credentials=credentials)# Creates an asset(s) from source file(s) and uploadinput_asset = pdf_services.upload(input_stream=input_stream, mime_type=PDFServicesMediaType.PDF)# Create parameters for the jobexport_pdf_to_images_params = ExportPDFtoImagesParams(export_pdf_to_images_target_format=ExportPDFToImagesTargetFormat.JPEG,export_pdf_to_images_output_type=ExportPDFToImagesOutputType.LIST_OF_PAGE_IMAGES,)# Creates a new job instanceexport_pdf_to_images_job = ExportPDFtoImagesJob(input_asset=input_asset,export_pdf_to_images_params=export_pdf_to_images_params,)# Submit the job and gets the job resultlocation = pdf_services.submit(export_pdf_to_images_job)pdf_services_response = pdf_services.get_job_result(location, ExportPDFtoImagesResult)# Get content from the resulting asset(s)result_assets = pdf_services_response.get_result().get_assets()output_file_path = "output/ExportPDFToImages"for (asset_index, asset) in enumerate(result_assets):save_output_file_path = f"{output_file_path}_{asset_index}.jpeg"stream_asset: StreamAsset = pdf_services.get_content(asset)# Creates an output stream and copy stream asset's content to itwith open(save_output_file_path, "wb") as file:file.write(stream_asset.get_input_stream())except (ServiceApiException, ServiceUsageException, SdkException) as e:logging.exception(f"Exception encountered while executing operation: {e}")if __name__ == "__main__":ExportPDFtoJPEG()

