Convert first 4 pages

Hello
Assuming very large document (e.g. RTF or TXT file) which need to be converted to PDF, I want to be able to convert only the first 4-5 pages of the original document and be able to quickly generate the PDF of it, so i can publish a quick preview of the document to the user.

Appreciate for some guidance or reference to some post which dealing with such scenario

Thanks much
Tal.F
Allscripts - dbMotion

@talfa009

Thanks for your inquiry. Please use the following code example to convert first five pages of document into PDF. Hope this helps you.

Document doc = new Document(MyDir + "in.rtf");
using (Stream stream = File.Create(MyDir + @"output.pdf"))
{
    PdfSaveOptions options = new PdfSaveOptions();
    options.PageIndex = 0;
    options.PageCount = 4;
    doc.Save(stream, options);
}