Search code examples
angularjspdf

How can I add a top and bottom border to specific columns while implementing jspdf print in Angular?


I need to implement jspdf print with certain conditions

  1. Some specific column need to bordered top and bottom
  2. Example image provided if any suggestion its very thankfulenter image description here

The above image showing underlines in some amounts I want to implement these structure.

I need to implement jspdf print with certain conditions


Solution

  • willDrawCell: function(data) {
        if (data.row.section === "body") {
           doc.setDrawColor(0, 0, 0);
           doc.setLineWidth(0.2);
           // draw bottom border
            doc.line(
                data.cell.x,
                data.cell.y + data.cell.height,
                data.cell.x + data.cell.width,
                data.cell.y + data.cell.height
            );
            // draw top border
            doc.line(
                data.cell.x + data.cell.width,
                data.cell.y,
                data.cell.x,
                data.cell.y
            );
            // draw left border
            doc.line(
                data.cell.x,
                data.cell.y + data.cell.height,
                data.cell.x,
                data.cell.y
            );
            // draw right border
            doc.line(
                data.cell.x + data.cell.width,
                data.cell.y,
                data.cell.x + data.cell.width,
                data.cell.y + data.cell.height
            );
        }
    }