Skip to main content

Retrieve Text, Metadata, or XMP From PDFs


Extract text, retrieve metadata, or retrieve XMP metadata from PDF documents.

Extract text from a PDF using the pdf-text endpoint. Extract metadata from a PDF using the pdf-info endpoint. Extract XMP metadata from a PDF using the pdf-xmp endpoint.

tip

Check out Getting Started and Task Roadmap if you are new to The DynamicPDF API.

Extract Text

Extract text from a PDF using the pdf-text endpoint. The following illustrates how easy it is to extract text from a PDF using this endpoint.

info

You can also specify the start page and page count properties to limit the pages to extract text from. Refer to the API documentation and the client library documentation for the pdf-text endpoint.

Calling Endpoint Directly

Call the endpoint directly by passing the API key in the request header and specifying the PDF's path as the data.

curl --location 'https://api.dpdf.io/v1.0/pdf-text'
--header 'Authorization: Bearer DP--api-key--'
--header 'Content-Type: application/pdf'
--data '@/C:/temp/solutions/text-metadata-xmp/fw4.pdf'

Run In Postman

Calling Endpoint Using Client Library

You can also call the endpoint using a client library rather than directly. The processing and syntax are similar for all six languages.

  • Create a new PdfText instance and pass a PdfResource instance to the constructor.
  • Call the PdfText instance's Process method and get the results as a PdfTextResponse which contains the extracted text as a JSON document.
public static void Run(String apiKey, String basePath)
{
PdfResource resource = new PdfResource(basePath + "/fw4.pdf");
PdfText pdfText = new PdfText(resource);
pdfText.StartPage = 1;
pdfText.PageCount = 2;
pdfText.ApiKey = apiKey;
PdfTextResponse response = pdfText.Process();
Console.WriteLine(PrettyPrintUtil.JsonPrettify(response.JsonContent));
}
Source: PdfTextExample

Retrieve Metadata

Retrieve metadata from a PDF using the pdf-info endpoint. The following illustrates how easy it is to extract text from a PDF using this endpoint.

info

Refer to the endpoint documentation and client library documentation for the pdf-info endpoint.

Calling Endpoint Directly

Call the endpoint directly by passing the API key in the request header and specifying the PDF's path as the data.

curl --location 'https://api.dpdf.io/v1.0/pdf-info'
--header 'Authorization: Bearer DP--api-key--'
--header 'Content-Type: application/pdf'
--data '@/C:/temp/solutions/text-metadata-xmp/fw4.pdf'

Run In Postman

Calling Endpoint Using Client Library

You can also call the endpoint using a client library rather than directly. The processing and syntax are similar for all six languages.

  • 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.
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

Retrieve XMP Metadata

Retrieve a PDF document's XMP metadata using the pdf-xmp endpoint.

info

Refer to the endpoint documentation and client library documentation for the pdf-xmp endpoint.

Calling Endpoint Directly

Call the endpoint directly by passing the API key in the request header and specifying the PDF's path as the data.

curl --location 'https://api.dpdf.io/v1.0/pdf-xmp'
--header 'Authorization: Bearer DP--api-key--'
--header 'Content-Type: application/pdf'
--data '@/C:/temp/solutions/text-metadata-xmp/fw4.pdf'

Run In Postman

Calling Endpoint Using Client Library

You can also call the endpoint using a client library rather than directly. The processing and syntax are similar for all six languages.

  • Create a new PdfXmp instance and pass a PdfResource instance containing the PDF.
  • Call the PdfXmp instance's Process method and the PDF's XMP metadata is returned as XML.
public static void Run(String apiKey, String basePath)
{
PdfResource resource = new PdfResource(basePath + "/fw4.pdf");
PdfXmp pdfXmp = new PdfXmp(resource);
pdfXmp.ApiKey = apiKey;
XmlResponse response = pdfXmp.Process();
Console.WriteLine(response.Content);
}
Source: PdfXmpExample
   Follow us on social media for latest news!