PageNumber at the bottom of the page.

PageNumber at the bottom of the page.

Forum member · Nov 3, 2011
Hello, I am trying to merge pdf documents. Some documents are created by Reprting Services and some are pre-generadted (these are smaller in size than others). When I try to add a page number at the bottom of the pages, pagesgenerated by SSRS show it properly, although pre-generated pages do not show page numbers as they are going out of page. Following is my code: ceTe.DynamicPDF.PageElements.PageNumberingLabel lblPageNumber = new ceTe.DynamicPDF.PageElements.PageNumberingLabel("Page %%CP%% of %%TP%%", 250, 750, 250, 25, Font.Helvetica, 12, RgbColor.Black); ceTe.DynamicPDF.PageElements.AnchorGroup anchorGroup = new ceTe.DynamicPDF.PageElements.AnchorGroup(lblPageNumber.Width, lblPageNumber.Height, Align.Left, VAlign.Top); anchorGroup.AnchorTo = ceTe.DynamicPDF.PageElements.AnchorTo.Margins; anchorGroup.Add(lblPageNumber); Template stampTemplate = new Template(); stampTemplate.Elements.Add(lblPageNumber); editor_DynamicPDF.StampTemplate = stampTemplate; editor_DynamicPDF.Sections.Begin(NumberingStyle.Numeric); foreach (var key_DynamicPDF in fileList.Keys) { var filename_DynamicPDF = fileList[key_DynamicPDF]; try { fileInfo_DynamicPDF = new ceTe.DynamicPDF.Merger.PdfDocument(filename_DynamicPDF); editor_DynamicPDF.Append(fileInfo_DynamicPDF); } catch { } } FileWrite(this.ReportFilePath, editor_DynamicPDF.Draw()); How do I solve this problem?

Re: PageNumber at the bottom of the page.

Support · Nov 3, 2011
Hello, Below is the sample code that uses the anchor group, page numbering label and stamp template correctly to add the page numbers at the bottom or the page. Please note that the x & y co-ordinates of the PageNumberingLabel are zero and the AnchorGroup is added to the template instead of PageNumberingLabel. If you want the page numbers to be at the bottom center of the page change the align property of the anchor group and set it to Align.Center. Similarly if you want the page numbers at the top of the page set the VAlign propert of the anchor group to VAlign.Top. Document doc = new Document(); Page pageLetter = new Page(PageSize.Letter); Page pageLegal = new Page(PageSize.Legal); Page pagetab = new Page(PageSize.Tabloid); doc.Pages.Add(pagetab); doc.Pages.Add(pageLetter); doc.Pages.Add(pageLegal); PdfDocument pdf = new PdfDocument(doc.Draw()); MergeDocument mergeDoc = new MergeDocument(pdf); PageNumberingLabel lblPageNumber = new PageNumberingLabel("%%CP%% of %%TP%%", 0, 0, 50, 12, Font.Helvetica, 12, TextAlign.Center); ceTe.DynamicPDF.PageElements.AnchorGroup anchorGroup = new ceTe.DynamicPDF.PageElements.AnchorGroup(lblPageNumber.Width, lblPageNumber.Height, Align.Left, VAlign.Bottom); anchorGroup.AnchorTo = ceTe.DynamicPDF.PageElements.AnchorTo.Margins; anchorGroup.Add(lblPageNumber); Template stampTemplate = new Template(); stampTemplate.Elements.Add(anchorGroup); mergeDoc.StampTemplate = stampTemplate; mergeDoc.Draw("final.pdf"); Thanks, ceTe Software Support Team.

Re: PageNumber at the bottom of the page.

Forum member · Nov 3, 2011
That worked. Thanks for your help.