Skip to main content

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 for more information illustrating how to call the endpoint directly as a REST call.

Run In Postman

API

The PdfInfo class encapsulates the pdf-info endpoint. A PdfInfo instance takes a PdfResource instance. A PdfResource is constructed from a PDF coming from a file, a byte array, or Stream.

public PdfInfo(PdfResource resource);

public class PdfResource : Resource
{
public PdfResource(string filePath, string resourceName = null);
public PdfResource(byte[] value, string resourceName = null);
public PdfResource(Stream data, string resourceName = null);
}
Source: PdfInfo.cs Source: PdfResource.cs

Example

A complete example is available via one of the following GitHub projects depending upon the language you wish to use.

LanguageGitHub Users Guide ProjectClassLocation/Package/Namespace
C#https://github.com/dynamicpdf-api/dotnet-client-examplesProgram.csnamespace PdfInfoExample
Gohttps://github.com/dynamicpdf-api/go-client-examplespdf-info-example.gogo-client-examples
Javahttps://github.com/dynamicpdf-api/java-client-examplesPdfInfoExample.javacom.dynamicpdf.client.api.examples
Node.jshttps://github.com/dynamicpdf-api/nodejs-client-examplesPdfInfoExample.jsnodejs-users-guide
PHPhttps://github.com/dynamicpdf-api/php-client-examplesPdfInfoExample.phpphp-client-examples
Pythonhttps://github.com/dynamicpdf-api/python-client-examplesPdfInfoExample.pypython-client-examples

The processing steps and syntax for all five languages are similar.

  • Create a PdfInfo instance and pass a PdfResource instance to the PdfInfo instance.
  • Call the PdfInfo instance's Process method to return the PDF's metadata as JSON.
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));
}
}
}
Source: PdfInfoExample
   Follow us on social media for latest news!