Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Apr 06, 2022 6:06 am

Hi.
First of all I must say I'm using FreeSpire (which is great for my using purpose).

I have a template file which has some textbox-es which I must fill them programmatically. Everything works very well, except for vertical alignment of text inside it. If the TextBox field is taller enough to fill two or three rows, and I fill in only a single row, the text is vertically centered in textboxes. I want to know if there is any possibility to fill those textboxes and align text to top-left, or bottom left.

Thanks

valimaties
 
Posts: 13
Joined: Sat May 08, 2021 5:19 pm

Wed Apr 06, 2022 7:54 am

Hello,

Thank you for your inquiry.
Sorry our Spire.PDF does not support setting the vertical alignment of the text of the textbox field. Please use the following code to achieve top-left alignment of the text in the textbox field.
Code: Select all
...
PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
textBoxField.TextAlignment = PdfTextAlignment.Left;
textBoxField.Multiline = true;
...

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Thu Apr 07, 2022 7:48 am

Hi Annika,
thanks for your quick reply.

When I made the pdf template, I set the textbox-es multiline property to true (by ticking the checkbox), and I assume that the setting from template will be loaded from the template, but now I realized that was not true.
Using your code and setting the Multiline property to true was solving my issue with vertical alignment of top-left .

Kind regards,
Vali

valimaties
 
Posts: 13
Joined: Sat May 08, 2021 5:19 pm

Thu Apr 07, 2022 7:56 am

Hello,

Glad to hear that.

If you encounter other issues related to our products in the future, please feel free to contact us.

Have a nice day!

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF