Report with rotating mvc

0

I'm having trouble generating a report in mvc, using the rotary. The problem is that it generates the pdf, as if I have been ignoring the html, it is all unformatted.

ob: for htm formatting, it's css in an external file.

I'm calling it like this:

    [HttpGet]
    public ActionResult ImprimeRequerimento(int processoId)
    {
        var requerimento = _processoAppServico.ObterRequerimentoProcesso(processoId);
        var v = new ViewAsPdf
        {
            ViewName = "RequerimentoProcesso",
            Model = requerimento               
        };
        return v;
    }

html view:

 @model GestaoProcesso.Aplicacao.ViewModels.ProcessoViewModel

@{    
    Layout = "null";
}

<h2>ObterRequerimento</h2>


<link href="~/Content/relReqProcesso.css" rel="stylesheet" />
<div class="table-wrap col-lg-11">
    <div class="box">
        <div class="box-body table-responsive no-padding">
            <table class="table">
                <tbody>
                    <tr>
                        <td class="modulos" colspan="4">Dados do Processo:</td>
                    </tr>
                    <tr>
                        <th class="nomeCampo" colspan="4">Nome do requerente / Razão Social</th>
                    </tr>
                    <tr>
                        <td class="valorCampo" colspan="4">@Html.DisplayFor(model => model.NomeCLiente)</td>
                    </tr>
                    <tr>
                        <th class="nomeCampo">
                            RG
                        </th>
                        <th class="nomeCampo">
                            Orgão
                        </th>
                        <th class="nomeCampo">
                            Data de Emissão
                        </th>
                        <th class="nomeCampo">
                            CPF/CNPJ
                        </th>
                    </tr>
                    <tr>
                        <td class="valorCampo">@Html.DisplayFor(model => model.Bairro)</td>
                        <td class="valorCampo"></td>
                        <td class="valorCampo"></td>
                        <td class="valorCampo">@Html.DisplayFor(model => model.Complemento)</td>
                    </tr>
                    <tr>
                        <th class="nomeCampo" colspan="4">
                            Endereço / CEP
                        </th>
                    </tr>
                    <tr>
                        <td class="campoCinza" colspan="4">@Html.DisplayFor(model => model.Rua)</td>
                    </tr>
                    <tr>
                        <th class="nomeCampo">
                            Telefone
                        </th>
                        <th class="nomeCampo" colspan="3">
                            Email
                        </th>
                    </tr>
                    <tr>
                        <td class="valorCampo">@Html.DisplayFor(model => model.Descricao)</td>
                        <td class="valorCampo" colspan="3">@Html.DisplayFor(model => model.Data)</td>
                    </tr>
                    <tr>
                        <td class="modulos" colspan="4">Dados do Processo:</td>
                    </tr>
                    <tr>
                        <th class="nomeCampo" colspan="2">
                            Registro IPTU
                        </th>
                        <th class="nomeCampo" colspan="2">
                            INSCRIÇÃO MERCANTIL
                        </th>
                    </tr>
                    <tr>
                        <td class="valorCampo" colspan="2"></td>
                        <td class="valorCampo" colspan="2"></td>
                    </tr>
                    <tr>
                        <td class="modulos" colspan="4">Solicitação do Processo:</td>
                    </tr>
                    <tr>
                        <th class="nomeCampo" colspan="4">
                            Assunto
                        </th>
                    </tr>
                    <tr>
                        <td class="valorCampo" colspan="4"></td>
                    </tr>
                    <tr>
                        <th class="nomeCampo" colspan="4">
                            Descrição
                        </th>
                    </tr>
                    <tr>
                        <td class="valorCampo" colspan="4" style="height 25vh;"></td>
                    </tr>
                    <tr>
                        <td class="modulos" colspan="4"></td>
                    </tr>
                    <tr>
                        <th class="nomeCampo" colspan="3">
                            Assinatura
                        </th>
                        <th class="nomeCampo">
                            Data
                        </th>
                    </tr>
                    <tr>
                        <td class="valorCampo" colspan="3"><p /></td>
                        <td class="valorCampo"><p /></td>
                    </tr>
                </tbody>
            </table>
        </div>        
    </div>
</div>

And here's what the PDF looks like:

    
asked by anonymous 19.05.2017 / 03:43

1 answer

0

I'm using the rotator with file css external because I'm using actionAsPdf and not ViewAsPDF , here it worked. I did so in view , as seen in this section below.

<link rel="stylesheet" type="text/css" href="~/Content/skin/PDFStyle.css" />

<table class="pdf-table" cellpadding="0" cellspacing="0">
@for (var i = 0; i < Model.Lista.Count; i++)
{
    <tbody>
        <tr>
            <td rowspan="2" style="height: 60px; width:50px;" class="noPadding">
                <img src="~/Content/images/logocourrieros.png" />
            </td>

and in the controller I did the following: a button any button calls the action Print , which calls in ActionAsPdf , the action Index that loads my view .

public ActionResult Print()
    {
        return new ActionAsPdf("Index");
    }

OBS: If you need to use ViewAsPDF , I found in searches that version 1.6.4 of the press has the css problem, I downgraded to version 1.6.3 only for confirm, and it took the css right, it is this tip if you want to test.

    
13.09.2017 / 20:22