public void SaveAsPdf()
{
//ExStart
//ExFor:PdfSaveOptions.PreserveFormFields
//ExFor:Document.Save(String)
//ExFor:Document.Save(Stream, SaveFormat)
//ExFor:Document.Save(String, SaveOptions)
//ExId:SaveToPdf_NewAPI
//ExSummary:Shows how to save a document to the PDF format using the Save method and the PdfSaveOptions class.
// Open the document
Document doc = new Document(MyDir + "Rendering.doc");
// Option 1: Save document to file in the PDF format with default options
doc.Save(MyDir + @"\Artifacts\Rendering.PdfDefaultOptions.pdf");
// Option 2: Save the document to stream in the PDF format with default options
MemoryStream stream = new MemoryStream();
doc.Save(stream, SaveFormat.Pdf);
// Rewind the stream position back to the beginning, ready for use
stream.Seek(0, SeekOrigin.Begin);
// Option 3: Save document to the PDF format with specified options
// Render the first page only and preserve form fields as usable controls and not as plain text
PdfSaveOptions pdfOptions = new PdfSaveOptions();
pdfOptions.PageIndex = 0;
pdfOptions.PageCount = 1;
pdfOptions.PreserveFormFields = true;
doc.Save(MyDir + @"\Artifacts\Rendering.PdfCustomOptions.pdf", pdfOptions);
//ExEnd
}