How to make PdfPage blank

PdfDocumentPageCollection does not have RemoveAt method as stated in documentation.

For my specific purpose bettor solution would be to make page blank. 

PdfPageBase has IsBlank property, but there is no actual method to make page blank there.



5 Replies

GK Gowthamraj Kumar Syncfusion Team June 23, 2021 02:28 PM UTC

Hi Mr Andrey, 
 
Thank you for contacting Syncfusion support. 
 
If your requirement want to insert a blank page, you can insert the new page in existing PDF document by using Insert method in PdfDocumentPageCollection class. Please find the below documentation link, 
 
If it is not your requirement, please share the excepted output, input document to analyze on our end. So, that it will be helpful for us to analyze and assist you further on this. 
 
Regards, 
Gowthamraj K 



MA Mr Andrey Voronov June 23, 2021 02:36 PM UTC

I need to remove page, or completely remove everything already drawn on the page. 

fPdfDocumentPageCollection does not have RemoveAt(pageindex)



GK Gowthamraj Kumar Syncfusion Team June 24, 2021 01:57 PM UTC

Hi Mr Andrey, 
 
Thank you for your update. 
 
We can remove the page from existing PDF document by using RemoveAt method from PdfLoadedPageCollection class. We do not have support for removing everything drawn from the page. As a workaround, we can remove the page and insert a new page based on that page index. We have attached the sample and output document for your reference. Kindly please try the sample on your end and let us know the result.

 
 
Please find the below code snippet this remove and add new page in a existing PDF document, 
//Create an instance of PdfDocument 
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(file)) 
{ 
       //Remove the second page in the PDF document 
       loadedDocument.Pages.RemoveAt(1); 
        
       loadedDocument.Pages.Insert(1); 
 
       MemoryStream stream = new MemoryStream(); 
       //Save and close the document 
       loadedDocument.Save(stream); 
       File.WriteAllBytes("../../../Output.pdf", stream.ToArray()); 
} 
 
 
Please let us know if you need any further assistance with this. 
 
Regards, 
Gowthamraj K 



MA Mr Andrey Voronov June 25, 2021 01:59 PM UTC

I am using latest 19.169 verson.  There is no  RemoveAt method  listed on   PdfLoadedPageCollection class:





GK Gowthamraj Kumar Syncfusion Team June 28, 2021 11:33 AM UTC

Hi Mr Andrey, 
 
Thank you for your update. 
 
As we said earlier, we can remove the page from existing PDF document by using RemoveAt method only from PdfLoadedPageCollection class. We do not have removeAt method from PdfDocumentPageCollection class, here you can insert the empty page from pdfdocument page collection. We request you to use the removeAt method from loaded page collection.  
 
Please find the below screenshot, 
 
 
 
 
Please let us know if you need any further assistance with this. 
 
Regards, 
Gowthamraj K 


Loader.
Up arrow icon