We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

LineAlignment does not work

Thread ID:

Created:

Updated:

Platform:

Replies:

140837 Nov 9,2018 03:23 PM UTC Nov 16,2018 06:01 AM UTC Xamarin.Android 7
loading
Tags: PDF
Vince
Asked On November 9, 2018 03:23 PM UTC

In my app I use PdfGrid's to show text in a pdf file. In the cells I also must add long text which has to be aligned vertical at the top like:

            var pdfGridParagraph3 = new Syncfusion.Pdf.Grid.PdfGrid();
            pdfGridParagraph3.Columns.Add(1);
            pdfGridParagraph3.Columns[0].Width = 200;
            var pdfGridRowParagraph3Details1 = pdfGridParagraph3.Rows.Add();
            pdfGridRowParagraph3Details1.Cells[0].Value = "This is a test. This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.";
            PdfStringFormat format = new PdfStringFormat();
            format.LineAlignment = PdfVerticalAlignment.Top;
            pdfGridRowParagraph3Details1.Cells[0].StringFormat = format; //NOT WORKING

Unfortunetly the long text is aligned in the middle of the row in stead off at the top of the row.

Do you have a solution?

KarthikeyanC [Syncfusion]
Replied On November 12, 2018 10:06 AM UTC

Hi Vince, 
Thank you for contacting Syncfusion support. 
We have created a sample to draw the PdfGrid in PDF with vertical alignment set to top. In the resulted PDF, the text are aligned at the top position of PdfGridCell bounds as expected. The reported mismatched text alignment issue is not reproduced in our end. We have shared the created sample in below link, kindly check the sample and modified it to reproduce the sample. So that it will be helpful for us to check the same and provide you the solution at the earliest. 

Regards, 
Karthikeyan  


Vince
Replied On November 12, 2018 12:06 PM UTC

Hi Karthikeyan,

In your sample there is only one cell in the pdfGridParagraph3.Rows. Aligning it has then no effect and my problem does not occur.

But if you use several cells in the pdfGridParagraph3.Rows with different text lengths then my problem occurs. 

Can you look again to this problem?

Best regards,

Vince.



KarthikeyanC [Syncfusion]
Replied On November 13, 2018 12:45 PM UTC

HI Vince, 
We have added multiple PdfGridCell in the PdfGridRow and set the different string length and string format alignment to every individual PdfGridCell. In The resulted PDF, the string format vertical alignment preserved as expected. Please find the sample and output PDF below for your reference. We suspect that the issue occurs in sample level. Could you please modify the sample to reproduce the issue in our side, it will be helpful for us to provide the solution earlier. 

Regards, 
Karthikeyan  


Vince
Replied On November 14, 2018 02:11 PM UTC

Hi KarthikeyanC,

I found the problem in my app. It is caused by my code:

pdfGridParagraph3.Columns[0].Format = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);

When removing the last parameter "PdfVerticalAlignment.Middle" the rows beneath the header of the grid are aligned correct at the top.

But without the last parameter "PdfVerticalAlignment.Middle" the header of the row is not aligned in the middle but at the top of the row.

Is there a way to align the header and the rows of the grid seperately?

Best regards,

Vince.

KarthikeyanC [Syncfusion]
Replied On November 15, 2018 12:27 PM UTC

Hi Vince, 
Thank you for your update. 
We can set line alignment of individual PdfGridCell using StringFormat property. Kindly refer the below code snippet to set line alignment to PdfGridCell. 
 
//Header cell. 
pdfGridHeader.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment. Middle); 
 
//Cell index 0 
pdfGridRowParagraph3Details1.Cells[0].StringFormat= new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Top);  
 
If we set the string format to particular column of the PdfGrid, then the column string format overrides the header and cells string format of the particular column. It is the default behavior. 
 
If separate string format required for header rows and cells, then we suggest to set the string format individually in PdfGridCell. 
Regards, 
Karthikeyan  


Vince
Replied On November 15, 2018 01:09 PM UTC

Yes, now it works.

I also had to set CellPadding (Top parameter) for the Cells to keep the text in the rows in line with the other PdfGrid's in the report.

Thanks for your support!

KarthikeyanC [Syncfusion]
Replied On November 16, 2018 06:01 AM UTC

Hi Vince, 
We are happy to know that the solution works. You may contact any time for further assistance.
Regards,
Karthikeyan
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;