Skip to main content

pdf


Use the pdf endpoint to create pages, PDF reports from DLEX files, convert images to PDF, convert Word documents to PDFs, and merge PDFs into a combined PDF.

Use the pdf endpoint to create PDF documents (cover pages for example), create documents/reports using DLEX files, convert images to PDFs, and to merge PDFs into a combined PDF. You can also combined the results from these tasks to merge into a single PDF document.

PDF Instructions
Instructions Using Client Libraries
pdf.instructions - JSON Schema

The pdf endpoint is much more complex than the other API endpoints. You must understand the pdf endpoint's schema for creating instructions. pdf.instructions - JSON Schema. Understanding the pdf endpoint requires understanding an instructions document, even if you plan on only using one of the client libraries and not calling the REST endpoint directly (Instructions Using Client Libraries).

Figure 1. The pdf endpoint uses an instructions.json document to process one or more input types.

info

Refer to the following Users Guide page if you need more information illustrating how to call the endpoint directly as a REST call.

LanguageGitHub Users Guide ProjectClassLocation/Namespace/Package
C#https://github.com/dynamicpdf-api/dotnet-client-examplesProgram.csnamespace PdfExample
Gohttps://github.com/dynamicpdf-api/go-client-examplespdf-example.gogo-client-examples
Javahttps://github.com/dynamicpdf-api/java-client-examplesPdfExample.javacom.dynamicpdf.client.usersguide
Node.jshttps://github.com/dynamicpdf-api/nodejs-client-examplesPdfExample.jsnodejs-users-guide
PHPhttps://github.com/dynamicpdf-api/php-client-examplesPdfExample.jsphp-client-examples
Pythonhttps://github.com/dynamicpdf-api/python-client-examplesPdfExample.pypython-client-examples
   Follow us on social media for latest news!

Simple Example (page Input)

The following code is a simple example illustrating the pdf endpoint with the page input type. The processing steps and syntax for the page input is the same for all five languages.

  • Create a new Pdf instance and create a new page as a PageInput instance.
  • Add page numbers using the PageNumberingElement class.
  • Format the PageNumberingElement instance and add them to the PageInput instance.
  • Call the Pdf instance's Process method and get the returned PDF.

Run In Postman

using DynamicPDF.Api;
using DynamicPDF.Api.Elements;
using System;
using System.IO;

namespace PdfExample
{
class Program
{
static void Main(string[] args)
{
Run("DP---api-key---", "C:/temp/dynamicpdf-api-usersguide-examples/");
}

public static void Run(String apiKey, String basePath)
{
Pdf pdf = new Pdf();
pdf.ApiKey = apiKey;
pdf.Author = "John Doe";
pdf.Title = "My Blank PDF Page";
PageInput pageInput = pdf.AddPage(1008, 612);
PageNumberingElement pageNumberingElement = new PageNumberingElement("1", ElementPlacement.TopRight);
pageNumberingElement.Color = RgbColor.Red;
pageNumberingElement.Font = Font.Courier;
pageNumberingElement.FontSize = 24;
pageInput.Elements.Add(pageNumberingElement);
PdfResponse pdfResponse = pdf.Process();
File.WriteAllBytes(basePath + "pdf-example-output.pdf", pdfResponse.Content);
}
}
}
Source: PdfExample
info

Note the above is a very simple example of using the pdf endpoint with the page input type. Be certain to review the other input types available with the pdf endpoint (Instructions Using Client Libraries).

   Follow us on social media for latest news!