Get the actual RECT parameters after using Rect.fromLTWH with PdfVerticalAlignment.middle in drawString function

Hi!

Is there a way to determine/calculate the "final" Rect coordinates of a first Rect (red box) after using the drawString function?  Named parameters used in drawString is as follows:

bounds: Rect.fromLTWH(x, y, 0, 0)
format: PdfStringFormat(lineAlignment: PdfVerticalAlignment.middle)

I need to have the 2nd Rect (green box) top aligned to the 1st Rect. 


Image_2833_1705747496642

Thank you very much.


6 Replies

RS RaashithAhamed SahulHameed Syncfusion Team January 22, 2024 03:07 PM UTC

Hi Trem,

 Currently, we are analyzing on this and we will update further details on January 23rd, 2024.

Regards,

Raashith Ahamed S



KS Karmegam Seerangan Syncfusion Team January 23, 2024 12:16 PM UTC

Hi Trem,


To determine the width and height of the text to be drawn, we can use measureString method in PdfFont. Kindly use the following UG link for reference, https://help.syncfusion.com/flutter/pdf/working-with-text#measuring-a-string

 

To draw text in a layout, we can use PdfTextElement to draw the text and determine the end positions using PdfLayoutResult. Kindly use the following UG link for reference, https://help.syncfusion.com/flutter/pdf/working-with-flow-layout


Regards,

Karmegam




R R replied to Karmegam Seerangan January 24, 2024 01:31 PM UTC

Thanks! I'll look into it.



JT Jeyalakshmi Thangamarippandian Syncfusion Team January 25, 2024 04:56 AM UTC

Most welcome, please check and get back to us.



R R January 30, 2024 06:33 PM UTC

Hello Jeyalakshmi Thangamarippandian,


Thanks for the heads up, I've managed to write the code to make what I envisioned to happen, as can be seen below, where the right column top-aligns with the left column no matter the number of lines entered.

Image_8433_1706639140694   


Image_1789_1706639195952


However, I hit a snag when it comes to text that has been word wrapped within the RECT. I'm wondering if there's another method that could be used with word wrapped text.

Image_5654_1706639523710


Again, thanks very much!


--

Thor



PR Padmini Ramamurthy Syncfusion Team January 31, 2024 08:57 PM UTC

Thanks for the update, Thor.

Please get back to us if you need any other assistance.


Loader.
Up arrow icon