Skip to content

Add PDF repair functionality#118

Open
microshine wants to merge 7 commits intomainfrom
repair-check-document
Open

Add PDF repair functionality#118
microshine wants to merge 7 commits intomainfrom
repair-check-document

Conversation

@microshine
Copy link
Contributor

@microshine microshine commented Jan 23, 2024

This pull request adds PDF repair functionality to the project. It includes the implementation of several repair rules and the necessary changes to the PDFRepair class. The PDF repair functionality allows for the detection and repair of various issues in PDF documents, such as incorrect EOL for cross-reference table entries and missing page references in annotations. This functionality will be useful for ensuring the integrity and correctness of PDF documents in the project.

const doc = await PDFDocument.load(raw);
const repair = new PDFRepair();
const report = await repair.checkDocument(doc);

switch (report.status) {
  case RepairStatus.requireClone:
    const clone = await doc.clone();
    break;
  case RepairStatus.repairable:
    await repair.repairDocument(doc);
    break;
  case RepairStatus.notNeeded:
    // No repair needed
    break;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant