Set Page count while saving

Hi,

I’m Saving a document as PDF in a stream, How can I pass the starting index and total number of pages to save.
e.g. If document has 200 pages then I only want to save 50-60 pages as pdf.

thank you,
Purnima

Hi Purnima,

Thanks for your inquiry. Please use PdfSaveOptions.PageCount and PdfSaveOptions.PageIndex as shown in following code snippet to achieve your requirements.

PdfSaveOptions.PageCount Property : Gets or sets the number of pages to save. Default is MaxValue which means all pages of the document will be rendered.

PdfSaveOptions.PageIndex Property : Gets or sets the 0-based index of the first page to save. Default is 0.

Document doc = new Document(MyDir + "in.docx");
using (Stream stream = File.Create(MyDir + "Out.pdf"))
{
    PdfSaveOptions options = new PdfSaveOptions();
    options.PageIndex = 10;
    options.PageCount = 40;
    doc.Save(stream, options);
}

Please let us know if you have any more queries.