I want to display the first page in a document which has 4 merge tags. I have used the code block below to do that. However, the merge tag name mentioned in the builderSupportingPage2Doc.MoveToMergeField(mergetagname) line does not contain any value when the PDF is generated. Please mention the solution for this issue. Also, is there a way by which I can display only the second or third page that is requested by the user.
Document SupportingPage_2Doc = new Document(documentTemplatePath + Constants.SupportingPage2);
if (!string.IsNullOrEmpty(pageNumber) && (pageNumber != Constants.AllPages))
{
DocumentBuilder builderSupportingPage2Doc = new DocumentBuilder(SupportingPage_2Doc);
builderSupportingPage2Doc.MoveToMergeField(pageNumber);
Section secSupportingPage2 = builderSupportingPage2Doc.CurrentSection;
SectionCollection sectionCollectionSupportingPage2 = SupportingPage_2Doc.Sections;
foreach (Section section in sectionCollectionSupportingPage2)
{
if (section != secSupportingPage2)
{
section.Remove();
}
}
}
document.AppendDocument(SupportingPage_2Doc, ImportFormatMode.KeepSourceFormatting);