ConvertFilesBatch

Small Business, production workflows

Requires the Small Business edition — in Delphi, C++Builder and Lazarus code create the library as TPDFlibSmallBusiness (unit PDFlibSmallBusiness) or TPDFlibEnterprise; the Small Business and Enterprise DLL and ActiveX builds provide it unchanged; the Single edition keeps the method, which returns an empty string and sets LastErrorCode to 901 (PDFLIB_ERROR_SMALLBUSINESS_REQUIRED)

Description

Runs a configured batch of existing PDF/X, PDF/E and PDF/R conversions and returns per-file results together with a delivery manifest identifying every successfully written output

Syntax

Delphi

Function TPDFlib.ConvertFilesBatch(Const RequestJSON: WideString): WideString; Virtual;

ActiveX

Function PDFlib::ConvertFilesBatch(RequestJSON As String) As String

DLL

const wchar_t* DLConvertFilesBatch(int InstanceID, const wchar_t* RequestJSON);
const char* DLConvertFilesBatchA(int InstanceID, const char* RequestJSON);

Parameters

RequestJSONJSON object whose root contains only jobs, an array of 1 through 64 entries; each job accepts input, output, an optional password and a preset object naming print-x4, engineering-e1 or raster-r1 with their preset-specific values

Return values

Returns JSON with schemaVersion, status, jobCount, deliveredJobs, failedJobs, jobs and manifest. A structurally valid batch can have status:"ok" with failed jobs and complete:false; invalid requests use error 906, cancellation returns status:"cancelled" with error 907, and the Single edition returns an empty string with error 901.

Request

{"jobs":[
  {"input":"drawing.pdf","output":"drawing-e1.pdf",
   "preset":{"name":"engineering-e1"}},
  {"input":"brochure.pdf","output":"brochure-x4.pdf","password":"",
   "preset":{"name":"print-x4","profileFile":"press.icc"}},
  {"input":"scan.pdf","output":"scan-r1.pdf",
   "preset":{"name":"raster-r1","dpi":144,"jpegQuality":90}}
]}

The root contains only jobs; each job accepts input, output, optional password and a preset object; unknown properties and incorrect JSON types are rejected

PresetParametersBehavior
print-x4Optional profileFileUses PDF/X-4 preparation; an omitted profile retains the document's existing output intent, and a missing suitable intent blocks conversion
engineering-e1NoneUses PDF/E-1 preparation; the source must already contain required information such as a document title
raster-r1dpi 72 to 300, default 144; jpegQuality 1 to 100, default 90Uses PDF/R raster conversion and requires a usable rendering backend

Safety and processing

The complete request is checked before conversion starts; outputs must be unique new local .pdf paths, cannot overlap any batch input or ICC profile, and never replace an existing destination

Each job uses an independent document loaded from captured input bytes, and failures do not stop later valid jobs; the selected document on the calling instance is retained; temporary instances reuse its rendering configuration, and successful jobs report the selected runtimeBackend ID together with renderingUsed

A finished output is published only after it has been saved and hashed; malformed requests publish no outputs, while a batch with individual conversion failures retains its successful deliveries

A batch supports 1 to 64 jobs; each input is limited to 256 MiB and 2048 pages, each output to 512 MiB, and each retained conversion report to 65536 characters

A supplied printing profile is captured once with a 16 MiB limit; the same captured bytes are used for conversion and their profileSha256 is retained with the normalized profile path in effectivePreset

Progress, cancellation and budgets

The root additionally accepts integer maxRasterPixels and maxEncodedBytes, each defaulting to 134217728, and maxOutputBytes, defaulting to 536870912; all range from 1 through 536870912 and apply independently to each job

PDF/R checks cumulative source raster geometry and JPEG bytes, uses a temporary disk spool for page images and applies the requested DPI at render scale 1; the caller's preview scale does not change the output page size

Output byte limits apply during writes, and file hashing uses a bounded streaming buffer; temporary files are removed after failure or cancellation

Progress is forwarded to the caller's typed and classic events; cancellation returns status:"cancelled", error 907, cancelledJobs and skippedJobs, while retaining already published files and their manifest entries

PDF/R observes page and native rendering cancellation points; PDF/X and PDF/E stop at available operation and I/O safe points, and external renderer response time depends on that backend; ResetAbort enables a subsequent request

Return values

Returns JSON with schemaVersion, status, jobCount, deliveredJobs, failedJobs, jobs and manifest; successful manifest entries contain the normalized output path, byte count, SHA-256, source SHA-256, job index and preset name and effectivePreset with the parameters actually applied

complete means all requested deliveries were written, as stated by completenessMeaning:"all-requested-deliveries-written"; it does not mean all possible standards rules were checked

Each successful conversion retains validationCompleteness:"not-reported" and fullCertification:false; the presets inherit the underlying converters' repair limits, font and profile dependencies, and basic checking coverage

Invalid requests and workflow failures use error 906; a structurally valid batch can return status:"ok" with failed jobs and complete:false, so callers must inspect the summary and per-file results

Single instances return an empty string with error 901; Small Business and Enterprise implement the operation; ActiveX uses IPDFlibrary9 or CoPDFlibrary.CreateEditionTools9, and Dylib provides the same names with cdecl

Run the shared workflow CLI example through the Delphi, Lazarus or C++Builder entry for the required edition, including progress and batch cancellation

TRIAL delivery retains the evaluation watermark on temporary output objects; batch conversion applies it before format conversion so raster output contains the mark inside its image data, while internal source snapshots remain unchanged

See also

ConvertToPDFX · ConvertToPDFE · ConvertToPDFR · Edition comparison