pdf-info
Use the pdf-info endpoint to upload a PDF document and return JSON describing the PDF.
The pdf-info
endpoint takes a PDF document and returns the following data as JSON:
- the metadata (title, author, keywords etc)
- any custom properties in the PDF,
- an array of pages with the size of each page,
- and an array of form fields and their name, value and available values (for select boxes).
info
Refer to the following Users Guide page if you need more information illustrating how to call the endpoint directly as a REST call.
- Calling the
pdf-info
endpoint using REST (pdf-info REST API).
The complete example is available via one of the following GitHub projects depending upon the language you wish to use.
Language | GitHub Users Guide Project | Class | Location/Package/Namespace |
---|---|---|---|
C# | https://github.com/dynamicpdf-api/dotnet-client-examples | Program.cs | namespace PdfInfoExample |
Java | https://github.com/dynamicpdf-api/java-client-examples | PdfInfoExample.java | com.dynamicpdf.client.api.examples |
Node.js | https://github.com/dynamicpdf-api/nodejs-client-examples | PdfInfoExample.js | nodejs-users-guide |
PHP | https://github.com/dynamicpdf-api/php-client-examples | PdfInfoExample.php | php-client-examples |
The processing steps and syntax for all four languages are similar.
- Create a
PdfInfo
instance and pass aPdfResource
instance to thePdfInfo
instance. - Call the
PdfInfo
instance'sProcess
method to return the PDF's metadata as JSON.
- C# (.NET)
- Java
- Node.js
- PHP
Available on NuGet:
Install-Package DynamicPDF.API
using DynamicPDF.Api;
using System;
namespace PdfInfoExample
{
class Program
{
static void Main(string[] args)
{
Run("DP.xxx--api-key--xxx", "C:/temp/dynamicpdf-api-usersguide-examples/");
}
public static void Run(string key, string basePath)
{
PdfResource resource = new PdfResource(basePath + "/DocumentA.pdf");
PdfInfo pdfInfo = new PdfInfo(resource);
pdfInfo.ApiKey = key;
PdfInfoResponse response = pdfInfo.Process();
Console.WriteLine(PrettyPrintUtil.JsonPrettify(response.JsonContent));
}
}
}
Available on NPM:
npm i @dynamicpdf/api
import {
PdfResource,
PdfInfo
} from "@dynamicpdf/api"
export class PdfInfoExample {
static async Run() {
var basePath = "C:/temp/dynamicpdf-api-usersguide-examples/";
var apiKey = "DP.xxx--api-key--xxx";
var resource = new PdfResource(basePath + "DocumentA.pdf");
var pdfInfo = new PdfInfo(resource);
pdfInfo.apiKey = apiKey;
var res = await pdfInfo.process();
if (res.isSuccessful) {
console.log(JSON.parse(res.content));
}
}
}
PdfInfoExample.Run();
Available on Maven:
https://search.maven.org/search?q=g:com.dynamicpdf.api
<dependency>
<groupId>com.dynamicpdf.api</groupId>
<artifactId>dynamicpdf-api</artifactId>
<version>1.0.0</version>
</dependency>
package com.dynamicpdf.api.examples;
import com.dynamicpdf.api.PdfInfo;
import com.dynamicpdf.api.PdfInfoResponse;
import com.dynamicpdf.api.PdfResource;
import com.dynamicpdf.api.util.PrettyPrintUtility;
public class PdfInfoExample {
public static void Run(String key, String basePath) {
PdfResource resource = new PdfResource(basePath + "DocumentA.pdf");
PdfInfo pdfInfo = new PdfInfo(resource);
pdfInfo.setApiKey(key);
PdfInfoResponse response = pdfInfo.process();
System.out.println(PrettyPrintUtility.prettyPrintJSON(response.getJsonContent()));
}
public static void main(String[] args) {
PdfInfoExample.Run("DP.xxx-api-key-xxx",
"C:/temp/dynamicpdf-api-usersguide-examples/");
}
}
Available as a Composer package:
composer require dynamicpdf/api
<?php
require __DIR__ . '/vendor/autoload.php';
use DynamicPDF\Api\PdfResource;
use DynamicPDF\Api\PdfInfo;
class PdfInfoExample
{
private static string $BasePath = "C:/temp/dynamicpdf-api-usersguide-examples/";
private static string $ApiKey = "DP.xxx--api-key--xxx";
public static function Run()
{
$resource = new PdfResource(PdfInfoExample::$BasePath . "DocumentA.pdf");
$pdfInfo = new PdfInfo($resource);
$pdfInfo->ApiKey = PdfInfoExample::$ApiKey;
$response = $pdfInfo->Process();
echo (json_encode($response));
}
}
PdfInfoExample::Run();