You can repair a Pdf document by analyzing it using the Repair function in Pdf4me. Moreover Repair Pdf can also help you recover pages, rebuild fonts, text etc.
// repairing
var res = Pdf4me.Instance.PdfAClient.RepairDocumentAsync(File.ReadAllBytes("myPdf.pdf")).GetAwaiter().GetResult();
// and writing the repaired PDF to disk
File.WriteAllBytes("repairedPdf.pdf", stampedPdf);
// setup the pdf4meClient
const pdf4meClient = pdf4me.createClient('YOUR API KEY')
// repair document
pdf4meClient.repairDocument(fs.createReadStream(path.join(__dirname, 'myPdf.pdf')))
.then(pdf => {
// and writing the resulting PDFs to disk
fs.writeFileSync(path.join(__dirname, 'repairedPdf.pdf'), pdf)
})
.catch(error => {
console.error(error)
})
// repairing
$res = $client->pdf4me()->repairDocument(
[
"file" => 'myPdf.pdf'
]);
//writing it to file
file_put_contents('repairedPdf.pdf', $res);
# setup the pdfA_client
pdfA_client = PdfAClient(pdf4me_client)
# protecting the PDF
repaired_pdf = pdfA_client.repair_document(
file=FileReader().get_file_handler(path='myPdf.pdf')
)
# writing the generated PDF to disk
with open('repairedPdf.pdf', 'wb') as f:
f.write(repaired_pdf)
Logging information about the request, e.g. timestamp.
Page
Name
Type
Description
Notes
documentId
String
Globally unique Id.
pageId
String
Globally unique Id.
pageNumber
Integer
PageNumber, starting with 1.
rotate
double
By how much the page was rotated from its original orientation.
thumbnail
byte
Thumbnail representing this particular page.
sourceDocumentId
String
Id of the document it was created from, e.g. in case of an extraction, the result's sourceDocumentId is the Id of the PDF the pages have been extracted from.
sourcePageNumber
Integer
Page number of the original page in the original document, e.g. let's assume document B consists of page number 4 of document A (extraction). Thus, document B's only page's sourcePageNumber is number 4.