I am trying to split a 'n' paged pdf file to 'n' number of pdf files containing 1 page each in ".net". For normal pdf files, PDFSharp is working fine but for corrupt file its showing errors listed down. When I use Adobe Reader and 'Save As' the file, the new file is uncorrupted one. But I do not want to do it manually. I tried to open the pdf in Adobe reader using 'Process' but I can't save from there without manually saving it. If I use other DLLs the job gets done but it adds watermark.
Errors while opening the PDF Doc:
• "Invalid entry in XRef table, ID=9, Generation=0, Position=0, ID of referenced object=1, Generation of referenced object=0"
• {"Unexpected character '0xffff' in PDF stream. The file may be corrupted. If you think this is a bug in PDFsharp, please send us your PDF file."}
• Object already in use exception.
For handling corrupt files through process I tried this:
Process p = new Process();
p.StartInfo.FileName = file;
p.Start();
p.Close();
corrupt = true;
inputDocument = PdfReader.Open(file, PdfDocumentOpenMode.Import);
Please help me ASAP... Thanks in advance.
Marvin ReidPosted Jan 19, 2021, 8:50 PM
You can split any number of pages within a PDF file into different PDFs using the LEADTOOLS SDK. This will also fix your corrupt file issue as the SDK supports the ability to load corrupted files. You can try the following code for this:
Anshit HayaranPosted May 12, 2020, 11:23 PM
Leon DPosted May 12, 2020, 8:03 PM
Salman BegPosted May 12, 2020, 8:54 AM