We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF Split

Hi Team,

I have requirement of splitting the PDF and download as single ZIP file.I am facing the issue like when i download the zip file the split pdf files are not available and the zip file is corrupt.Please help me as soon as possible.I fyou have better code snippet than this please send me this also.I have used .NET based zip class objects to create and add zip file and pdf file entries respectively.


parameter “inputPdfObject” is the input pdf file and it is a byte array object of the uploaded pdf.

MemoryStream memoryStream = new MemoryStream();
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(@"…\App_Data\Aspose.Pdf.lic");
if (Aspose.Pdf.Document.IsLicensed)
{
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(new MemoryStream(inputPdfObject));
var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true);
int pageCount = 1;
foreach (Page pdfPage in pdfDocument.Pages)
{
Aspose.Pdf.Document newDocument = new Aspose.Pdf.Document();
newDocument.Pages.Add(pdfPage);
ZipArchiveEntry zipFileEntry = archive.CreateEntry(“Split” + pageCount + “.pdf”);
using (Stream ZipFile = zipFileEntry.Open())
{
Stream splitStream = new MemoryStream();
newDocument.Save(splitStream, SaveFormat.Pdf);
byte[] splitPdf = ReadFully(splitStream);
ZipFile.Write(splitPdf, 0, splitPdf.Length);
}

pageCount++;
}
outputByteArray = memoryStream.ToArray();
}

Response.Clear();
Response.ContentType = “application/octet-stream”;
Response.AddHeader(“Content-Disposition”, “attachment; filename=Split.zip”);
Response.BinaryWrite(byteArrayObject);

Hi Navaneethan,


Thanks for contacting support.

I am not entirely certain if the issue is related to our API or its occurring due to ZipArchiveEntry class. However in order to be certain, can you please separately try splitting your source files to individual files without performing archive operation and see if the resultant files are properly being converted and share your findings.

In case the issue is occurring for Aspose.Pdf for .NET, please share the resource files so that we can further look into this matter. We are sorry for this inconvenience.