Splitting PDF File results in Blank pages

Hi,


I am trying to split a file if it is more than 5 mb size and finally i am getting all blank pages
Please give us a solution to this ASAP.

Stream stream = new MemoryStream( file );
Document pdfDocument = new Document( stream );

if( GetDocSize( pdfDocument ) <= maxFileSize ) {
list.Add( fileName, file );
} else {

List documents = new List();

Document pdf = new Document();

foreach( Page page in pdfDocument.Pages ) {

long pageSize = GetPageSize( page );
long docSize = GetDocSize( pdf );

if( ( pageSize + docSize ) < maxFileSize ) {
pdf.Pages.Add( page );
} else if( docSize == 0 && pageSize >= maxFileSize ) {
OptimizePage( page );
pageSize = GetPageSize( page );
if( pageSize >= maxFileSize ) {
throw new Exception( String.Format( “Cannot save page #{0}: page size of {1:n2}Kb is greater than allowed”, page.Number, pageSize / 1024 ) );
} else {
pdf.Pages.Add( page );
}
} else if( docSize > 0 && docSize < maxFileSize ) {
OptimizePage( page );
pageSize = GetPageSize( page );
if( ( pageSize + docSize ) < maxFileSize ) {
pdf.Pages.Add( page );
} else {
documents.Add( pdf );
pdf = new Document();
if( pageSize < maxFileSize ) {
pdf.Pages.Add( page );
} else {
throw new Exception( String.Format( “Cannot save page #{0}: page size of {1:n2}Kb is greater than allowed”, page.Number, pageSize / 1024 ) );
}
}
}

}

Thanks
Raj

Hi Raj,


Thanks for contacting support.

In above shared code snippet, the GetPageSize(…), GetDocSize(…) and OptimizePage(…) methods are not defined and I am afraid I am unable to test the scenario. Can you please share your input document and a sample project, so that we can again try replicating the issue in our environment. We are sorry for this inconvenience.