API reference › PDF/A & Conformance
pdfConvertFile
One-call file-to-file conversion of any loadable PDF into
SI32 __stdcall pdfConvertFileA(PPDF IPDF, const char* InFile, const char* OutFile, SI32 ConfType, UI32 Flags, const char* RGBProfile, const char* CMYKProfile, const char* OwnerPwd, void* UserData, TOnFontNotFoundProc OnFontNotFound, TOnReplaceICCProfile OnReplaceICCProfile);
SI32 __stdcall pdfConvertFileW(PPDF IPDF, const wchar_t* InFile, const wchar_t* OutFile, SI32 ConfType, UI32 Flags, const wchar_t* RGBProfile, const wchar_t* CMYKProfile, const wchar_t* OwnerPwd, void* UserData, TOnFontNotFoundProc OnFontNotFound, TOnReplaceICCProfile OnReplaceICCProfile);
function pdfConvertFileA(const IPDF: PPDF; const InFile, OutFile: PAnsiChar; ConfType: Integer; Flags: Cardinal; const RGBProfile, CMYKProfile, OwnerPwd: PAnsiChar; const UserData: Pointer; OnFontNotFound: TOnFontNotFoundProc; OnReplaceICCProfile: TOnReplaceICCProfile): Integer; stdcall;
function pdfConvertFileW(const IPDF: PPDF; const InFile, OutFile: PWideChar; ConfType: Integer; Flags: Cardinal; const RGBProfile, CMYKProfile, OwnerPwd: PWideChar; const UserData: Pointer; OnFontNotFound: TOnFontNotFoundProc; OnReplaceICCProfile: TOnReplaceICCProfile): Integer; stdcall;
Purpose. One-call file-to-file conversion of any loadable PDF into a conformance target (TConformanceType: the PDF/A a-levels, PDF/X, and the other ct* targets this SDK supports).
Description. The whole pipeline in one call, on a fresh in-memory document: opens InFile (with OwnerPwd when supplied), imports it completely, applies the conversion fixes the target demands — transparency flattening where the target forbids it, embedding of non-embedded simple fonts, LZWDecode re-encoding to FlateDecode, and for the PDF/X targets a real DeviceRGB-to-DeviceCMYK transcode of vector/text color through the supplied CMYK profile — then runs the conformance machinery (CheckConformance semantics: target version + identity metadata), validates the imported source and reports violations through the callbacks, attaches the appropriate OutputIntent (the CMYK profile for PDF/X, the RGB/sRGB profile for PDF/A), and writes OutFile. The callbacks mirror pdfCheckConformance: OnFontNotFound lets the host substitute a missing font, OnReplaceICCProfile lets it supply profiles on demand.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle (its current contents are replaced by the conversion workspace). |
InFile, OutFile | Source path and destination path. |
ConfType | The TConformanceType target. |
Flags | Conformance-check flags, as for pdfCheckConformance. |
RGBProfile, CMYKProfile | ICC profile paths for the OutputIntent / the PDF/X color transcode. |
OwnerPwd | Password for an encrypted source, or empty. |
UserData, OnFontNotFound, OnReplaceICCProfile | Violation-callback context, as for pdfCheckConformance. |
Return value. 0 on success; -354 when the conversion completed but content had to be withheld to satisfy the target; -1 for an unusable handle, an unwritable output, or an internal failure; -2 for an unreadable source or a wrong password.
C# (P/Invoke)
public static extern int pdfConvertFileW(IntPtr IPDF, [MarshalAs(UnmanagedType.LPWStr)] string InFile, [MarshalAs(UnmanagedType.LPWStr)] string OutFile, int ConfType, uint Flags, [MarshalAs(UnmanagedType.LPWStr)] string RGBProfile, [MarshalAs(UnmanagedType.LPWStr)] string CMYKProfile, [MarshalAs(UnmanagedType.LPWStr)] string OwnerPwd, IntPtr UserData, TOnFontNotFoundProc OnFontNotFound, TOnReplaceICCProfile OnReplaceICCProfile);
public static extern int pdfConvertFile(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string InFile, [MarshalAs(UnmanagedType.LPStr)] string OutFile, int ConfType, uint Flags, [MarshalAs(UnmanagedType.LPStr)] string RGBProfile, [MarshalAs(UnmanagedType.LPStr)] string CMYKProfile, [MarshalAs(UnmanagedType.LPStr)] string OwnerPwd, IntPtr UserData, TOnFontNotFoundProc OnFontNotFound, TOnReplaceICCProfile OnReplaceICCProfile);
public static extern int pdfConvertFileA(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string InFile, [MarshalAs(UnmanagedType.LPStr)] string OutFile, int ConfType, uint Flags, [MarshalAs(UnmanagedType.LPStr)] string RGBProfile, [MarshalAs(UnmanagedType.LPStr)] string CMYKProfile, [MarshalAs(UnmanagedType.LPStr)] string OwnerPwd, IntPtr UserData, TOnFontNotFoundProc OnFontNotFound, TOnReplaceICCProfile OnReplaceICCProfile);
Conversion
pdfConvertFileW
pdfConvertFile
pdfConvertFileA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.