RepairQDFFile
Debugging, Document repair
Description
Repairs a QDF PDF after human edits have changed stream lengths or object byte positions
The repair pass scans object boundaries without trusting stale cross-reference offsets, recalculates stream lengths, updates indirect length objects, and rebuilds the free list, cross-reference table, trailer, startxref, and /Size
Stream data containing endstream and endobj lines is preserved when the object has an unambiguous QDF stream marker. Invalid QDF input and repeated markers for the same object are rejected before the destination is opened, preserving an existing output file even during in-place repair
Syntax
Delphi
Function TPDFlib.RepairQDFFile(Const InputFileName, OutputFileName: WideString): Integer;DLL
int DLRepairQDFFile(int InstanceID, const wchar_t* InputFileName, const wchar_t* OutputFileName);
int DLRepairQDFFileA(int InstanceID, const char* InputFileName, const char* OutputFileName);ActiveX
Function PDFlib::RepairQDFFile(InputFileName As String, OutputFileName As String) As LongParameters
| InputFileName | The edited QDF PDF |
|---|---|
| OutputFileName | The repaired PDF path, which may be identical to the input path |
Return values
| 1 | The edited QDF was repaired |
|---|---|
| 0 | The input was not a repairable QDF or the destination could not be written |
Errors
LastErrorCode 106 reports invalid QDF structure, 107 reports repair failure, and 305 reports an output write failure
Remarks
The complete source is repaired in memory and then written to an exclusively created temporary file in the destination directory. The file is flushed and closed before a same-volume replacement publishes the result. A write, flush or replacement failure preserves the existing destination bytes and returns error 305; input read failures return 401
The destination directory must allow temporary file creation and replacement. Windows targets that are read-only or opened without delete sharing cannot be replaced. The existing target DACL permissions are copied to the temporary file before any repaired data is written; inaccessible permissions, a target without an explicit DACL or an EFS-encrypted target cause error 305. Successful replacement creates a new file identity and does not preserve alternate data streams or ordinary file attributes. Temporary files are removed after ordinary success or failure; abrupt process termination may leave a temporary file behind. This API does not guarantee survival of power loss or of concurrent changes by another writer