Report with Rotary mvc

Asked

Viewed 657 times

0

I’m having trouble generating a report on mvc, using the rotary. The problem is that it generates the pdf, as if I have been ignoring the html, it is all without formatting.

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

I’m calling it that way:

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

view html:

 @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 this is how the PDF looks:inserir a descrição da imagem aqui

  • How is the View RequerimentoProcesso? You can put it in the question?

  • I put the view html and a print of how PDF looks. vlw

  • Guys, has anyone ever had a similar problem, and who can help me? Thanks

  • I can give you an answer, but it involves trading the Rotary for another package. It will suit you?

  • i’m taking a look at the reportviewer, but can indicate @Ciganomorrisonmendez, no problems.

1 answer

0

I’m using the rotating file css external because I’m using actionAsPdf and not ViewAsPDF, here 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 as follows: a button any button calls the action Print, which calls on the ActionAsPdf, the action Index who carries my view.

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

OBS: In case you need to use the ViewAsPDF, I found in research that the version 1.6.4 of the rotary is with the css problem, I downgraded to version 1.6.3 just to confirm, and he took the css right, is this tip there if you want to test.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.