This demo uses the New DevExpress PDF Document API (PdfDocument) to manage PDF pages. You can process the predefined sample file or supply your own document. To do the latter, select Upload a File in the file selection drop-down menu.
Select the required action and specify corresponding settings. Use the Process PDF button to update the document and download the result.
Select a Document
Sample_Main.pdf
using DevExpress.Docs.Pdf;
Stream AddPage(Stream documentStream, double width, double height) {
using var doc = new PdfDocument(documentStream);
doc.Pages.Add((float)width, (float)height);
var outputStream = new MemoryStream();
doc.Save(outputStream);
return outputStream;
}
Stream DeletePages(Stream documentStream, IEnumerable<int> pageRange) {
using var doc = new PdfDocument(documentStream);
foreach(var index in pageRange) {
if(index < 0 || index >= doc.Pages.Count)
continue;
doc.Pages.RemoveAt(index);
}
var outputStream = new MemoryStream();
doc.Save(outputStream);
return outputStream;
}
Stream DuplicatePages(Stream documentStream, IEnumerable<int> pageRange) {
using var doc = new PdfDocument(documentStream);
foreach(var index in pageRange) {
if(index < 0 || index >= doc.Pages.Count)
continue;
doc.Pages.Add(doc.Pages[index].Clone());
}
var outputStream = new MemoryStream();
doc.Save(outputStream);
return outputStream;
}