首页 > 解决方案 > ASP.NET - SVG 到 PDF

问题描述

我正在尝试将存在文件 svg 的视图转换为 PDF。见下图。 在此处输入图片描述 看到“Febraban”这个词消失了……有人知道为什么吗?如果图像来自 PNG,系统运行完美,但格式为 .svg 不 :(

请参阅以下代码:

CSHTML:

<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>

控制器:

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

    public ActionResult Gerar()
    {

        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")
        };
    }
}

我希望你能帮助我!

标签: asp.net-mvcpdfsvgrotativa

解决方案


推荐阅读