Hi,
We have a requirement to split PDF files into smaller files using bookmarks. Also while splitting we need to start from a page immediately before the page on which the bookmark is located. We are using Aspose.Pdf.Kit to do that. But splitting each file based on bookmarks is taking too much time (varies between 10 - 30 secs) per file. As a requirement we have to process around 40,000 files. If splitting each file takes that much time we will be doomed.
Following is a code snippet used for doing that. Can any one from the Aspose team help us out urgently please?
Thanks & Regards,
Partha
------------------------------------------------------------------------------------------------------------------------
String InputFile = "Somefile.pdf"
String RootPath = "C:\"
string bookmarkXMLPath = Path.Combine(RootPath, "bookmark.xml");
PdfContentEditor _editorSourceFile = new PdfContentEditor();
_editorSourceFile.BindPdf(InputFile);
// generating XML file thats having bookmark detail of input PDF.
_editorSourceFile.ExportBookmarksToXML(bookmarkXMLPath);
_editorSourceFile = null;
XmlDocument doc = new XmlDocument();
doc.Load(bookmarkXMLPath);
string FileNameWithoutExtn = Path.GetFileNameWithoutExtension(InputFile);
XmlNodeList nl = doc.SelectNodes("//Title//@Page");
PdfFileEditor pdfEditor = new PdfFileEditor();
int FileNumber = 0;
for (int j = 0; j < nl.Count; j++)
{
int start = -1, end = -1;
string[] attValues1 = nl[j].Value.Split(new char[] { ' ' });
start = Convert.ToInt32(attValues1[0]) - 1; // Page Number
DateTime startTime = DateTime.Now;
FileNumber++;
string FileName = String.Format("{0}{1}.pdf", FileNameWithoutExtn, FileNumber.ToString());
FileName = System.IO.Path.Combine(RootPath, @"SplitResult/" + FileName);
if (j == nl.Count-1)
{
pdfEditor.SplitToEnd(InputFile, start, FileName);
}
else
{
string[] attValues2 = nl[j + 1].Value.Split(new char[] { ' ' });
end = Convert.ToInt32(attValues2[0]) - 2; // Page Number
pdfEditor.Extract(InputFile, start, end, FileName);
intTotalFilesSplitted++;
}
TimeSpan creationTime = DateTime.Now - startTime;
}
doc = null;
File.Delete(bookmarkXMLPath);