Я использую Rotativa ActionAsPDF для создания PDF представления, но свойство background-image не будет работать. Однако, это работает, если я возвращаю Действие как обычное представление.
ReportController:
public ActionResult CertificateAsPdf(int courseid, string type, int owningmtuid, int? attendeeid, int? agencyid, int? canineCertificationId)
{
return new ActionAsPdf("Certificate", new { courseid = courseid, type = type, attendeeid = attendeeid, owningmtuid = owningmtuid, agencyid = agencyid, canineCertificationId = canineCertificationId })
{
FileName = "Certificate.pdf",
PageOrientation = Rotativa.Options.Orientation.Landscape,
};
}
public ActionResult Certificate(int courseid, string type, int owningmtuid, int? attendeeid, int? agencyid, int? canineCertificationId)
{
// Logic to get data
return View("MTUCertificate", model);
}
MTUCertificateView:
<style>
.mtulogo {
background-image: url("@Url.Action("getimage", "mtu", new { area = "dataadministration", path = Model.MTULogoImage })");
background-size: contain;
background-position: center;
background-repeat: no-repeat;
height: 200px;
}
</style>
У меня проблема фоновое изображение не загружается. Параметр пути Model.MTULogoImage имеет UN C, сохраненный в базе данных в формате \\ ipaddress \ websitename \ logos \ mtulo go .png
Действие GetImage:
public ActionResult GetImage(string path)
{
string contentType = MimeMapping.GetMimeMapping(Path.GetFileName(path));
return File(@path, contentType);
}
Опять же, если я возвращаю только обычный просмотр, у меня нет проблем, это когда я меняю его на return new ActionAsPDF
, когда у меня начинаются проблемы.