As part of the KDAN ecosystem, ComPDF provides powerful PDF APIs for document conversion, parsing, OCR, compression, watermarking, and workflow automation.
ComPDF API Samples provides runnable examples that show how to authenticate, create tasks, upload files, and retrieve results across common ComPDF API workflows.
If you find these samples helpful, please consider giving us a ⭐ Star on GitHub! Have feedback or questions? Join the conversation in our Discussions.
Why ComPDF API Samples?
- Faster onboarding — Start from working examples instead of building request flows from scratch.
- Broad API coverage — Explore conversion, extraction, OCR, watermarking, and document-processing workflows.
- Reusable request patterns — Reuse authentication, task creation, upload, and result retrieval logic in your own tools.
- Docs-aligned examples — Cross-check each sample with the official API reference and guides.
ComPDF PDF API is organized around the REST standard and provides you with a simple document-upload, document-process, document-download workflow. Supporting various programming languages (such as Java, Python, C#, PHP, Swift, JavaScript, etc.), ComPDF API offers rich PDF functionalities, including conversion, document editor, data extraction, and so forth.
Before integrating the below PDF capabilities, you can register a free ComPDF API account to process 200+ API calls per month without costs and limitations.
This GitHub repository provides public access to code examples that demonstrate how to programmatically submit requests to the ComPDF API service.
Before you begin, you may need to do some preparatory work.
- Register a free ComPDF API account using email only.
- Obtain the project ID and its related key from the API Keys section of the console.
- To start requesting the ComPDF API, please read the comprehensive API reference for the function you need to call.
You can get accessToken and related verification information by sending your publicKey and SecretKey . AccessToken will expire after 12 hours. When calling the subsequent interface, you must carry this token in the request header: Authorization: Bearer {accessToken}.
Before running each sample program, look for a comment that reads:
public_key_******
secret_key_******
and replace ****** with your API Keys.
A task ID is automatically generated for you based on the type of PDF tool you choose. You can provide the callback notification URL. After the task processing is completed, we will notify you of the task result through the callback interface. You can perform other operations according to the task result, such as downloading the result file.
Upload the original file and bind the file to the task ID. The field parameter is used to pass the JSON string to set the processing parameters for the file. Each file will generate automatically a unique filekey.
Please note that a maximum of five files can be uploaded for a task ID and no files can be uploaded for that task after it has started.
After the file is uploaded, the file processing starts and the download link of the corresponding result file is obtained according to the filekey of each file
After you've successfully sent an API Call using these examples, take a look at the Documentation for each API endpoint for a full description of parameters you can adjust to customize your solution.
- Convert PDF to/ from other formats using PDF online tools
- Convert PDF to Image (JPG, PNG) with ComPDF API and Java
- Convert Excel to PDF Using Java - Free PDF Converter API
- Experience ComPDF Web Demo on any browser
ComPDF has a professional R&D team that produces comprehensive technical documentation and guides to help developers. Also, you can get an immediate response when reporting your problems to our support team.
- For detailed information, please visit our guides page.
- For technical assistance, please reach out to our technical support.
- To get more details and an accurate quote, please contact our sales team.
The code and sample materials are available under the repository's published license terms. Review the repository license before reusing the examples in your own projects.