pdf-xmp
Use the pdf-xmp endpoint to extract xmp meta-data from a PDF.
Use the pdf-xmp
endpoint to extract xmp meta-data from a PDF. It uses an HTTP POST to send a PDF as binary and then returns the xmp metadata as an XML response. The pdf-xmp
endpoint takes an HTTP POST form submission, where the PDF is sent as binary in the form's body.
Refer to the following Users Guide page if you require more information illustrating how to call the endpoint directly as a REST call.
- Calling the
pdf-xmp
endpoint using REST (pdf-xmp REST API).
API
- C# (.NET)
- Java
- Node.js
- PHP
- Go
- Python
The PdfXmp
class encapsulates the pdf-xmp
endpoint. A PdfXmp
instance takes an PdfResource
instance. An PdfResource
is constructed from a PDF coming from a file, a byte array, or stream.
public PdfXmp(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);
}
The PdfXmp
class encapsulates the pdf-xmp
endpoint. A PdfXmp
instance takes a PdfResource
instance. A PdfResource
is constructed from a PDF coming from a file, a byte array, or Inputstream
.
public PdfXmp(PdfResource resource);
public class PdfResource extends Resource
{
public PdfResource(String filePath, String resourceName);
public PdfResource(String filePath);
public PdfResource(byte[] value, String resourceName);
public PdfResource(byte[] value);
public PdfResource(InputStream data, String resourceName);
public PdfResource(InputStream data);
}
The PdfXmp
class encapsulates the pdf-xmp
endpoint. A PdfXmp
instance takes a PdfResource
instance. A PdfResource
is constructed from a PDF coming from a file or a byte array.
export class PdfXmp extends Endpoint {
constructor(resource);
}
export class PdfResource extends Resource {
/**
* Initializes a new instance of the `PdfResource` class.
* @param {string | Buffer[]} input The pdf file path. | The byte array of the pdf file.
* @param {string} resourceName The name of the resource.
*/
constructor(pdf, resourceName);
The PdfXmp
class encapsulates the pdf-xmp
endpoint. A PdfXmp
instance takes a PdfResource
instance. A PdfResource
is constructed from a PDF coming from a file or a byte array.
class PdfXmp extends Endpoint
{
public function __construct(PdfResource $resource)
}
class PdfResource extends Resource
{
/**
*
* Initializes a new instance of the PdfResource class.
*
* @param string|array|stream $filePath The pdf file path or the byte
* array of the pdf file or the stream of the pdf file.
* @param ?string $resourceName The name of the resource.
*/
public function __construct($file, ?string $resourceName = null)
The PdfXmp
class encapsulates the pdf-xmp
endpoint. A PdfXmp
instance takes an PdfResource
instance. An PdfResource
is constructed from a PDF coming from a file or a byte array.
/* Represents the pdfresource. */
type PdfXmp struct {
}
/**
* Initializes a new instance of the `PdfXmp` class.
* @param {PdfResource} resource The image resource of type `PdfResource`.
*/
func NewPdfXmp(resource resource.PdfResource) *PdfXmp
func NewPdfResourceWithResourcePath(resource string, resourceName string) PdfResource
func NewPdfResourceWithByteValue(resource string, resourceName string) PdfResource
The PdfXmp
class encapsulates the pdf-xmp
endpoint. A PdfXmp
instance extends the Endpoint
class and takes a PdfResource
instance. A PdfResource
extends the Resource
class and is constructed from a PDF coming from a file, a byte array, or io.BytesIO
.
class PdfXmp(Endpoint):
'''
Represents the pdf xmp endpoint.
'''
def __init__(self, resource):
'''
Initializes a new instance of the PdfXmp class.
Args:
resource (PdfResource): The image resource of type PdfResource.
'''
Example
A 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 PdfXmpExample |
Go | https://github.com/dynamicpdf-api/go-client-examples | pdf-xmp-example.go | go-client-examples |
Java | https://github.com/dynamicpdf-api/java-client-examples | PdfXmpExample.java | com.dynamicpdf.client.examples |
Node.js | https://github.com/dynamicpdf-api/nodejs-client-examples | PdfXmpExample.js | nodejs-users-guide |
PHP | https://github.com/dynamicpdf-api/php-client-examples | PdfXmpExample.php | php-client-examples |
Python | https://github.com/dynamicpdf-api/python-client-examples | PdfXmpExample.py | python-client-examples |
The processing steps and syntax are similar for all five languages.
- Create a new
PdfXmp
instance and pass aPdfResource
instance containing the PDF. - Call the
PdfXmp
instance'sProcess
method and the PDF's XMP metadata is returned as XML.
- C# (.NET)
- Java
- Node.js
- PHP
- Go
- Python
using DynamicPDF.Api;
using System;
namespace PdfXmpExample
{
class Program
{
static void Main(string[] args)
{
Run("DP.xxx-api-key-xxx", "C:/temp/dynamicpdf-api-usersguide-examples/");
}
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);
}
}
}
import {
PdfResource,
PdfXmp
} from "@dynamicpdf/api"
export class PdfXmpExample {
static async Run() {
var basePath = "C:/temp/dynamicpdf-api-usersguide-examples/";
var apiKey = "DP.xxx-api-key-xxx";
var resource = new PdfResource(basePath + "fw4.pdf")
var pdfXmp = new PdfXmp(resource);
pdfXmp.apiKey = apiKey;
var res = await pdfXmp.process();
if (res.isSuccessful) {
console.log(res.content);
}
}
}
await PdfXmpExample.Run();
package com.dynamicpdf.api.examples;
import com.dynamicpdf.api.PdfResource;
import com.dynamicpdf.api.PdfXmp;
import com.dynamicpdf.api.XmlResponse;
import com.dynamicpdf.api.util.PrettyPrintUtility;
public class PdfXmpExample {
public static void Run(String apiKey, String basePath)
{
PdfResource resource = new PdfResource(basePath + "fw4.pdf");
PdfXmp pdfXmp = new PdfXmp(resource);
pdfXmp.setApiKey(apiKey);
XmlResponse response = pdfXmp.process();
System.out.println(PrettyPrintUtility.prettyPrintJSON(response.getContent()));
}
public static void main(String[] args) {
PdfXmpExample.Run("DP.xxx-api-key-xxx",
"C:/temp/dynamicpdf-api-usersguide-examples/");
}
}
<?php
require __DIR__ . '/vendor/autoload.php';
use DynamicPDF\Api\PdfResource;
use DynamicPDF\Api\PdfXmp;
class PdfXmpExample
{
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(PdfXmpExample::$BasePath . "fw4.pdf");
$pdfXmp = new PdfXmp($resource);
$pdfXmp->ApiKey = PdfXmpExample::$ApiKey;
$response = $pdfXmp->Process();
echo ($response->Content);
}
}
PdfXmpExample::Run();
func main() {
resource := resource.NewPdfResourceWithResourcePath("C:/temp/dynamicpdf-api-samples/fw4.pdf", "fw4.pdf")
xmp := endpoint.NewPdfXmp(resource)
xmp.Endpoint.BaseUrl = "https://api.dpdf.io/"
xmp.Endpoint.ApiKey = "DP.xxx-api-key-xxx"
resp := xmp.Process()
res := <-resp
if res.IsSuccessful() == true {
fmt.Print(string(res.Content().Bytes()))
}
}
from dynamicpdf_api.pdf_xmp import PdfXmp
from dynamicpdf_api.pdf_resource import PdfResource
from Shared import *
def pdf_xmp_info(api_key, full_path):
resource = PdfResource(full_path + "fw4.pdf")
pdf_info = PdfXmp(resource)
pdf_info.api_key = api_key
response = pdf_info.process()
print(response.content)
if __name__ == "__main__":
pdf_xmp_info(api_key, base_path + "/get-xmp-metadata-pdf-xmp-endpoint/")