Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PDF repair functionality #118

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

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