Can I set background color on PageNumberingLabel?

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for .NET (v4)  /  Can I set background color on PageNumberingLabel?

DynamicPDF Merger for .NET (v4) Forum

I am merging many PDF docs together and each one already has its own Page X of Y in the bottom right corner. I'd like to use a PageNumberingLabel to provide Page X of Y over the entire new merged PDF document and place that label in the same position as the existing one. I've got the PageNumberingLabel working and placed where I want, however I just need to be able set its background color to white (as opposed to transparent) so that the existing Page X of Y doesn't show through. Is it possible somehow to either set the background color of the PageNumberingLabel or alternatively, remove existing text on merged PDFs so I can use the new overall Page X of Y PageNumberingLabel?

Thanks
Steve
Posted by a ceTe Software moderator
Hello Steve,

It is not possible to set the background color for the PageNumberingLabel, however you can do this by adding a rectangle in the same X, Y position and fill it with white color. Add the page numbering label on the rectangle so that the previous text will not be visible.

Thanks,
ceTe Software Support Team.
Thanks for the suggestion. In trying to use a Rectangle, I'm finding that even though I choose a fill color, the original text still shows through. I'm currently using violet just so I can see the rectangle on the PDF. Even so, the original Page X of Y from the merged PDf still shows through almost as though the fillcolor is semi-transparent.  Am I missing something?

Here is my code:
ceTe.DynamicPDF.PageElements.Rectangle rectangle = new ceTe.DynamicPDF.PageElements.Rectangle(650,0, 70, 15, RgbColor.Black, RgbColor.Violet, 1, LineStyle.Solid);
                        Template documentTemplate = new Template();
                        PageNumberingLabel pageNumberingLabel = new PageNumberingLabel("Page %%CP%% of %%TP%%", 0, 0, 715, 32, ceTe.DynamicPDF.Font.Helvetica, 8, ceTe.DynamicPDF.TextAlign.Right, RgbColor.Black);
                        pageNumberingLabel.PageOffset = -2;
                        AnchorGroup group = new AnchorGroup(pageNumberingLabel.Width, pageNumberingLabel.Height, Align.Center, VAlign.Bottom);
                        group.AnchorTo = AnchorTo.Edges;
                        group.Add(rectangle);
                        group.Add(pageNumberingLabel);
                        documentTemplate.Elements.Add(group);
                        _mergeDoc.Template = documentTemplate;
                        _mergeDoc.Pages[0].ApplyDocumentTemplate = false;
                        _mergeDoc.Pages[1].ApplyDocumentTemplate = false;
Posted by a ceTe Software moderator
Hello,

The reason the text is still transparent is because you are adding the elements to the template and the template gets applied to the document in the background of all pages. The solution in this case would be to use StampTemplate that applies the template in the foreground.

Below is the modified line of code that will solve your problem:

        _mergeDoc.StampTemplate = documentTemplate;

Thanks,
ceTe Software Support Team
That worked perfect. Thank you.

All times are US Eastern Standard time. The time now is 4:48 PM.