Removing borders in titles pdfmake file

49 Views Asked by At

could you help me please? in my javascript function below where I create a pdf to bring a table with various information, I am not able to remove the border of the objects:

{   
colSpan: 4,
text: 'Relatório de Ordens de Serviço Resumido',
fontSize: 18,
alignment: 'left',
margin: [0, 0, 0, 20]
},
'',
'',
'',
{
colSpan: 4,
text: [
    {
        text: "PERÍODO SELECIONADO\n",
        fontSize: 10
    },
    periodo                           
],
alignment: 'right',
margin: [0, 0, 0, 20]
}

And :

      const linhaData = [{ text: 'Data: ' + dataHoje, colSpan: 8, alignment: 'right', margin: [0, 10, 0, 0] }];
        corpo.push(linhaData);

I already tried to put the property border: [false, false, false, false] but it did not work. I tried several ways but I can't remove the border. Can anyone help me resolve this please? Thanks!

js function:

function exportaPdf(conteudo, dataInicial, dataFinal) {

const periodo = `${formatarData(dataInicial)} a ${formatarData(dataFinal)}`;

let corpo = [
    [   
        {   
            colSpan: 4,
            text: 'Relatório de Ordens de Serviço Resumido',
            fontSize: 18,
            alignment: 'left',
            margin: [0, 0, 0, 20]
        },
        '',
        '',
        '',
        {
            colSpan: 4,
            text: [
                {
                    text: "PERÍODO SELECIONADO\n",
                    fontSize: 10
                },
                periodo                           
            ],
            alignment: 'right',
            margin: [0, 0, 0, 20]
        },
        '',
        '',
        '',
    ],
    [
        { text: 'Data', style: 'tableHeader' },
        { text: 'Número OS', style: 'tableHeader' },
        { text: 'Jira', style: 'tableHeader' },
        { text: 'Cliente', style: 'tableHeader' },
        { text: 'Contato Posto', style: 'tableHeader' },
        { text: 'Placa', style: 'tableHeader' },
        { text: 'Descrição Serviço', style: 'tableHeader' },
        { text: 'Valor', style: 'tableHeader' }
    ]
];

let totalValor = 0;

conteudo.forEach((ordem) => {
    let valorProdutos = sumProdutos(ordem.ProdutosOS);
    let valorTotalOrdem = 0;
    ordem.ServicosOS.forEach((servico, index) => {
        let valorServico = servico.Valor;
        if (index === 0) {
            valorServico += valorProdutos;
        }
        valorTotalOrdem += valorServico;

        const valorString = 'R$ ' + valorServico.toFixed(2);
        const dataInclusaoFormatted = ordem.DataInclusao ? formatDate(convertTicksToDate(ordem.DataInclusao)) : '';

        corpo.push([dataInclusaoFormatted || '', ordem.NumeroOS || '', ordem.TicketQTHD || '', ordem.NomeEmpresa || '', ordem.ContatoEmpresa || '', ordem.RegistroVeiculo || '', servico.Descricao || '', valorString || '']);
    });
    totalValor += valorTotalOrdem;
});

const totalValorString = 'R$ ' + totalValor.toFixed(2);
corpo.push([{ text: 'Total:', colSpan: 7 }, '', '', '', '', '', '', totalValorString]);

const colunaEsquerda = [{ width: '*', text: '', border: [false, false, false, false] }];
const colunaDireita = [{ width: '*', text: '', border: [false, false, false, false] }];

const hoje = new Date();
const dataHoje = ('0' + hoje.getDate()).slice(-2) + "-" + ('0' + (hoje.getMonth() + 1)).slice(-2) + "-" + hoje.getFullYear();
const linhaData = [{ text: 'Data: ' + dataHoje, colSpan: 8, alignment: 'right', margin: [0, 10, 0, 0] }];
corpo.push(linhaData);



let docDefinition = {
    pageOrientation: 'landscape',
    pageSize: 'A3',
    margin: [0, 20, 0, 0],
    content: [
        {
            columns: [
                colunaEsquerda,
                {   
                    width: 'auto',
                    table: {
                        headerRows: 1,
                        body: corpo,
                        dontBreakRows: true,
                        widths: 'auto',
                    }
                },
                colunaDireita
            ]
        }
    ],
    styles: {
        tableHeader: {
            fillColor: '#CCCCCC',
            bold: true,
        }
    }
};

pdfMake.createPdf(docDefinition).download('relatorio_os_resumido' + dataHoje + ".pdf");

function sumProdutos(produtos) {
    let sum = 0;
    produtos.forEach((produto) => {
        sum += produto.Valor;
    });
    return sum;
}
}

If you guys need more information please let me know

0

There are 0 best solutions below