问题
Is there a way we can delete the first page of the PDF using iTextSharp?
回答1:
There's no direct way to remove pages from a PDF using iTextSharp.
However, you can copy all the pages you want from a PDF and skip the pages you don't want. In your case you'd copy out all but the first page.
I wrote a method that does this based on the code I found on this blog entry.
回答2:
PdfReader reader_SecondPdf = new PdfReader(pdf_of_Second_File);
for (j = 2; j <= reader_SecondPdf.NumberOfPages; j++)
{
}
回答3:
using itext 7 (thanks to @mkl)
public static void ExtractPagesFromPdf(string inputFile, string outputFile, int start, int end)
{
PdfReader inputPdf = new PdfReader(inputFile);
PdfDocument docIn = new PdfDocument(inputPdf);
PdfWriter outputWriter = new PdfWriter(outputFile);
PdfDocument docOut = new PdfDocument(outputWriter);
// retrieve the total number of pages
int pageCount = docIn.GetNumberOfPages();
if (end < start || end > pageCount)
{
end = pageCount;
}
var merge = new PdfMerger(docOut);
merge.Merge(docIn, start, end);
merge.Close();
}
from archive.org snapshot using itextsharp 5.x http://web.archive.org/web/20110619070947/http://www.jamesewelch.com:80/2008/11/14/how-to-extract-pages-from-a-pdf-document/
来源:https://stackoverflow.com/questions/2907354/delete-first-page-from-pdf-using-itextsharp