public ActionResult GeneratePdf(int id)
{
var labelRepository = new LabelRepository();
var label = labelRepository.GetLabel(id);
if (String.IsNullOrEmpty(label.PDFLocation))
{
var action = Url.Content("~/Label/ViewPdf/" + id); //doc
Doc theDoc = new Doc();
string filename = Guid.NewGuid().ToString();
string path = Server.MapPath("~/" + filename + ".pdf");
theDoc.AddImageUrl("action");
theDoc.Save(path);
theDoc.Clear();
label.PDFLocation = path;
labelRepository.Save();
return base.File(path, "application/pdf");
}
else
{
return base.File(label.PDFLocation, "application/pdf");
}
}
这不会添加我的图像 url,所以我的 pdf 不会打开,所以我可以看到它。有什么想法吗?-
最佳答案
在例子中here ,一个完整的 URL 被传递给 AddImageUrl()
函数,而不是 URL 的片段,如您的示例所示。
也许您需要调用 RouteUrl()
以便您可以获得完整的 Url 以传递给您的 AddImageUrl()
方法?
关于c# - 我的图像不会添加 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5128957/