webgio / Rotativa

Rotativa, /rota'tiva/. Make Pdf from Asp.Net MVC. Available on Nuget https://www.nuget.org/packages/Rotativa
http://letsfollowtheyellowbrickroad.blogspot.it/search/label/Rotativa
MIT License
621 stars 224 forks source link

SVG to PDF #198

Open joaowick opened 5 years ago

joaowick commented 5 years ago

I am trying to convert from view that there is file svg to PDF. See image below.

image

See that the word "Febraban" was disappeared... Does anyone know why?

See the codes below:

CSHTML

@{
    Layout = null;
}

<html>

<head>
    @Styles.Render("~/Content/Site.css")
    <title>Certificado</title>

</head>
<body>
    <table style="width:100%; height:100%;">
        <tr>
            <td style=" background: #e4e4e2 url('../../Content/Imagens/Imagem_Direita_AQ.svg') top right no-repeat; background-size: auto 100%; text-align: center;">
                <h1 class="txt-font-certificado">C E R T I F I C A D O</h1>
                <p class="txt-18-preto">
                    Declaremos que
                </p>
                <p class="txt-30-azul-Participante">
                    ÉLITA BORGES SIMIONATO
                </p>
                <p class="txt-18-preto">
                    participou do
                </p>
                <p class="txt-20-azul-evento">
                    8º Congresso Combate e Prevenção a Lavagem de Dinheiro
                <p align="center" class="txt-20-azul-evento">e ao Financiamento do Terrorismo</p>
                <p class="txt-18-preto">
                    de 7/6 a 12/6/18, na cidade de São Paulo/SP,
                </p>
                <p class="txt-18-preto">
                    promovido pela Federação Brasileira de Bancos. 
                </p>
                <p class="txt-18-preto">
                    Carga horária: 18 horas.
                </p>
                <br />
                <img class="txt-assinatura" src="~/Content/Imagens/Assinatura.png" />
            </td>
        </tr>
    </table>
    @using (Html.BeginForm("Gerar", "Pdf", FormMethod.Post))
    {
        <button type="submit">Gerar PDF</button>
    }
</body>
</html>

CONTROLLER

public class PdfController : Controller { [HttpGet] public ActionResult Certificado() { return View(); }

    public ActionResult Gerar()
    {
        //Esse deu certo, porém perde qualidade do SVG.
        return new ActionAsPdf("Certificado")
        {

            PageSize = Rotativa.Options.Size.A4,
            PageOrientation = Rotativa.Options.Orientation.Landscape,
            PageMargins = new Rotativa.Options.Margins(0, 0, 0, 0),
            FileName = Server.MapPath("~/Content/Certificado.pdf")
        };
    }
}
MrCodeB commented 5 years ago

I am also having some issues with SVG. It seems like that Rotativa can not handle all SVG elements.

For example -> I can group elements with <g> but when i try to reuse this element using the <use> statement, they will not appear in the PDF. This Code... `

<g id="test">
    <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
    <circle cx="50" cy="50" r="20" stroke-width="2" fill="green" />
    <circle cx="50" cy="50" r="10" stroke-width="2" fill="black" />
</g>
<use href="#test" x="100" y="100" />
<use href="#test" x="200" />

` ...will become this in browser firefox_2019-04-17_12-13-18 ...but this in PDF Acrobat_2019-04-17_12-13-48

As you can see, the elements in <g> are shown, but the <use> statement is simply not rendered

Same when i try to use <clipPath>. Instead of clipping the elements outside the <clipPath> everything will disappear in PDF.