Customize grid pdf border

There appears to be a single border style configuration for left, right, top, and bototm:

https://ej2.syncfusion.com/vue/documentation/api/grid/pdfThemeStyle/

Is it possible to turn off left/right border, and only keep top/bottom border? That is, I'd like to match the pdf border styling to the default html border styling as shown at the following link:

https://ej2.syncfusion.com/vue/documentation/grid/pdf-export/pdf-cell-style-customization/

Preview the first grid, and then export to pdf. Compare the html and pdf grids. Th




7 Replies

JC Joseph Christ Nithin Issack Syncfusion Team August 5, 2022 03:50 AM UTC

Hi Bill,


  Greetings from Syncfusion support.




Currently we are validating your query, we will provide further details on or before 9th August, 2022. We appreciate your patience until then.


Regards,

Joseph I.



VB Vinitha Balasubramanian Syncfusion Team August 26, 2022 03:28 PM UTC

Hi Bill,


Thanks for your patience.


Query : Customize grid pdf border


We have analyzed your query, you want turn off left/right border while performing pdf exporting the Grid. We have achieved your requirement using pdfQueryCellInfo event.


On that event, we have changed default width of the Grid columns using pdf borders method and apply the changed width to the each cell of the Grid component.


Kindly refer the below code and sample for your references.


[App.Vue]

 

pdfQueryCellInfo(args) {

      if (

        args.column.field == "OrderID" ||

        args.column.field == "CustomerID" ||

        args.column.field == "ShipAddress" ||

        args.column.field == "EmployeeID"

      ) {

        let leftrightpdfborders = new PdfBorders();

        leftrightpdfborders.right.width = 0;

        leftrightpdfborders.left.width = 0;

 

        args.cell.style = { borders: leftrightpdfborders };

        args.cell.style = { borders: leftrightpdfborders };

 

        if (args.column.field == "OrderID") {

          let rightpdfborders = new PdfBorders();

          rightpdfborders.right.width = 0;

          args.cell.style = { borders: rightpdfborders };

        }

        if (args.column.field == "EmployeeID") {

          let leftpdfborders = new PdfBorders();

          leftpdfborders.left.width = 0;

          args.cell.style = { borders: leftpdfborders };

        }

      }

    }


Sample link : https://codesandbox.io/s/vue-template-forked-tb2x4f


API reference : https://ej2.syncfusion.com/vue/documentation/api/grid/#pdfquerycellinfo


Please get back to us if you need further assistance


Regards,

Vinitha Balasubramanian



BN Bill Naples August 26, 2022 06:09 PM UTC

Thanks. What about the header row cells? Setting style border from pdfHeaderQueryCellInfo seems to have no effect.


And also how do you clear border on aggre



VB Vinitha Balasubramanian Syncfusion Team August 29, 2022 06:47 PM UTC

Hi Bill,


Thanks for your update


Currently we have prepared a sample based on your last update, facing some complexities to achieve your requirement.


We will update further details on 01/09/2022. Until then, we appreciate your patience.


Regards,

Vinitha Balasubramanian  



BN Bill Naples August 31, 2022 09:19 AM UTC

Thank you Vinitha.



VB Vinitha Balasubramanian Syncfusion Team September 1, 2022 05:18 PM UTC

Hi Bill,


We are sorry for the inconvenience.


Since we are facing some difficulties on the sample to achieve your requirement while performing PDF export action, we will update the further details on or before Sep 5th, 2022. Until then we appreciate your patience.


Regards,

Vinitha Balasubramanian



JS Johnson Soundararajan S Syncfusion Team March 19, 2024 02:31 PM UTC

Hi Bill Naples,


We reviewed your query. We understand that you want to customize the border styles in the columns header. So we tried to achieve the requirement by doing some customization in the sample when you click the Pdf Export button in the grid’s toolbar.


Please refer to the below sample and code snippet for more information.


Code sample :


App.vue

 

 

    CustomPDF: function () {

      let documentPdfDocument = new PdfDocument();

 

      //Add a page.

      let page1PdfPage = document.pages.add();

      let pdfGridPdfGrid = new PdfGrid();

 

      //Add columns

      pdfGrid.columns.add(4);

 

      //Add headers

      pdfGrid.headers.add(1);

 

      let leftrightborders = new PdfBorders();

      leftrightborders.right.width = 0;

      leftrightborders.left.width = 0;

      let leftborders = new PdfBorders();

      leftborders.left.width = 0;

      let rightborders = new PdfBorders();

      rightborders.right.width = 0;

 

      let headerPdfGridRow = pdfGrid.headers.getHeader(0);

      // Add the header value and borders styles

      header.cells.getCell(0).value = 'Order ID';

      header.cells.getCell(0).style.borders = rightborders;

      header.cells.getCell(1).value = 'Customer ID';

      header.cells.getCell(1).style.borders = leftrightborders;

      header.cells.getCell(2).value = 'Ship Address';

      header.cells.getCell(2).style.borders = leftrightborders;

      header.cells.getCell(3).value = 'Employee ID';

      header.cells.getCell(3).style.borders = leftborders;

 

      let pdfGridRow1PdfGridRow;

      for (var i = 0i < this.data.lengthi++) {

        // Add the new rows and set the data

        pdfGridRow1 = pdfGrid.rows.addRow();

        pdfGridRow1.cells.getCell(0).value = this.data[i].OrderID.toString();

        pdfGridRow1.cells.getCell(0).style.borders = rightborders;

        pdfGridRow1.cells.getCell(1).value = this.data[i].CustomerID;

        pdfGridRow1.cells.getCell(1).style.borders = leftrightborders;

        pdfGridRow1.cells.getCell(2).value = this.data[i].ShipAddress;

        pdfGridRow1.cells.getCell(2).style.borders = leftrightborders;

        pdfGridRow1.cells.getCell(3).value = this.data[i].EmployeeID.toString();

        pdfGridRow1.cells.getCell(3).style.borders = leftborders;

      }

 

      // drawing a grid

      pdfGrid.draw(page1new PointF(1010));

 

      // save the document

      document.save('Output.pdf');

 

      // destroy the document

      document.destroy();

    },

 


Sample : Rfcim2 (forked) - StackBlitz


Screenshot :
 


Please get back to us, if you need further assistance.


Regards,

Johnson Soundararajan S



Loader.
Up arrow icon