0

I created an UI to export angularjs grid to PDF using PDF Make, it was succeeded, but I want align only two columns to right in the table. I used below code for that,

 exporterPdfCustomFormatter: function (docDefinition) {     
     docDefinition.styles.tableStyle = {
        alignment:'right'
     };
     return docDefinition;
 }

That code is work fine for align all columns to right in the table. how can i change that code to align right only for two columns in the table?

1
  • 1
    does anyone even know how to do this? maybe playtest around more till you figure it out because I don't think a lot of people know this Commented Sep 10 at 18:12

2 Answers 2

1

Try this way. This should aligh only third column. Addopt accordingly to your needs.

exporterPdfCustomFormatter: function (docDefinition) {
  var table = docDefinition.content[0].table;

  // Loop through each row in the table body
  table.body.forEach(function(row, rowIndex) {
    // Skip header row if needed
    if (rowIndex === 0) return;

    // Apply right alignment to column index 2
    row[2].alignment = 'right';
  });

  return docDefinition;
}
Sign up to request clarification or add additional context in comments.

1 Comment

This code will work for table header alignment
0

I added exporterPdfAlign: 'right' to columnDefs's column definition, then issue was fixed.

ex:

$scope.gridOptions = {
    columnDefs: \[

        { field: 'name', displayName: 'Name', exporterPdfAlign: 'right' },  
................

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.