Right align PdfCompositeField

I have a PdfCompositeField that's intended to render the page number in the footer, as in "Page 1 of 1". I'd like this text to be aligned right. Normally I'd do this by measuring the size of the rendered text and then using that width value to determine the X value for the Draw method. But this does not seem to work with the PdfCompositeField. Any help is appreciated.


5 Replies

JT Jeyalakshmi Thangamarippandian Syncfusion Team March 20, 2024 02:03 PM UTC

Hi,

We have created a sample that meets our requirements, and we have attached it for your reference. Please try it on your end and let us know if you require any further assistance.

Sample:

https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample_F1873161644215349.zip

Regards,

Jeyalakshmi T



CK Chris K March 20, 2024 04:03 PM UTC

Thank you for the response. It looks like this approach measures the width of the footer text based on an assumed number of pages:

            string text = "Page 100 of 100";

            SizeF size = font.MeasureString(text);

The trouble is that when generating a PDF from dymanic content we don't know the total number of pages and moreover don't know ahead of time what page we're on. So won't this result in an assumed measurement that doesn't match the exact measurement and thus a footer that isn't always aligned to the right?




JT Jeyalakshmi Thangamarippandian Syncfusion Team March 21, 2024 03:03 PM UTC

Hi Chris,

Currently the page number field will be rendered based on bounds which provided and it doesn't change based on the dynamic content. So it is not possible to add the dynamic position on the page number fields.  

However, we have created a workaround solution to meet your requirement by drawing the page number directly using page graphics. Kindly try this sample on your end and let us know the details.

Sample:

https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample_F18731613259045.zip

Regards,

Jeyalakshmi T



CK Chris K replied to Jeyalakshmi Thangamarippandian March 28, 2024 04:09 PM UTC

Thank you for taking the time to look into this. It does work as advertised!



KS Karmegam Seerangan Syncfusion Team March 29, 2024 04:52 AM UTC

We are glad to hear that the issue has been resolved on your end. Please get back to us if you need any other assistance.


Loader.
Up arrow icon