//Converting loaded file to Byte array
byte[] dataBytes = File.ReadAllBytes("loaded.pdf");
//Saving individual pages as PdfDocument
List<PdfDocument> seperatePDF = SeperateAsPDF(dataBytes); |
public static List<PdfDocument> SeperateAsPDF(byte[] myFile)
{
//Load document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(myFile);
List<PdfDocument> PdfList = new List<PdfDocument>();
for(int i = 0; i < loadedDocument.Pages.Count; i++)
{
PdfDocument doc = new PdfDocument();
doc.ImportPageRange(loadedDocument, i, i);
PdfList.Add(doc);
}
return PdfList;
} |
//Load document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Output.pdf");
//Sets pattern.
const string destFilePattern = "Output" + "{0}.pdf";
//Split the pages into separate documents.
loadedDocument.Split(destFilePattern);
//close the document
loadedDocument.Close(true); |
//Converting loaded file to Byte array
byte[] dataBytes = File.ReadAllBytes("loaded.pdf");
//Saving individual pages as PdfDocument
List<byte[]> seperatePDF = SeperateAsPDF(dataBytes); |
public static List<byte[]> SeperateAsPDF(byte[] myFile)
{
//Load document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(myFile);
List<PdfDocument> pdfBytes= new List<PdfDocument>();
for(int i = 0; i < loadedDocument.Pages.Count; i++)
{
MemoryStream stream = new MemoryStream();
PdfDocument doc = new PdfDocument();
doc.ImportPageRange(loadedDocument, i, i);
doc.Save(stream);
pdfBytes.Add(stream.ToArray());
stream.Dispose();
}
return pdfBytes;
} |