-3
iTextSharp를 사용하여 .NET 응용 프로그램에서 PDF를 만듭니다. 저장을 위해 서버에 PDF를 저장/작성할 필요가 없습니다. 사용자 로컬 컴퓨터에 파일을 만드십시오. 아래에 게시 된 컨트롤러. 내가 어디로 잘못 가고 있는지 확실하지 않습니다.iTextsharp PDF 생성 오류
"암시 에 'System.Web.Mvc.FileResult'을 입력 '문자열을'변환 할 수 없습니다 오류 CS0029는"
[HttpPost]
public FileResult DailyReport(string path ="")
{
path = !String.IsNullOrWhiteSpace(path) ? path : String.Format("~/downloads/daily-report.pdf");
var report = new Document(PageSize.LETTER, 10, 10, 10, 10);
PdfWriter.GetInstance(report, new FileStream(MapPath(path), FileMode.OpenOrCreate));
report.Open();
var table = new Table(2, 1) { Width = 100, Border = 0, Cellpadding = 2 };
table.AddCell(
new Cell(new Paragraph("Daily Schedule", new Font(Font.TIMES_ROMAN, 18, Font.BOLD)))
{
Border = 0,
HorizontalAlignment = Element.ALIGN_CENTER,
Colspan = 2
});
table.AddCell(new Cell { Colspan = 2, Border = 0, Leading = 2 });
report.Add(table);
report.Close();
return path;
}
public static string MapPath(string path)
{
return (path.StartsWith("~") ? System.Web.HttpContext.Current.Server.MapPath(path) : path);
}
이 문제를 해결하는 방법 : '반환 경로가'오류를 던지고있다 오류?
어떤 문제가 있었는지 또는 질문하지 않았으므로 어느 부분이 잘못 될지 잘 모릅니다. 오류가 있습니까? 그것은 무엇을하고 있으며, 여러분이 기대하는 것과 어떻게 다른가? – Amy
@Amy 질문이 업데이트되었습니다. 가져 오는 중 "오류 CS0029 암시 적으로 'string'형식을 'System.Web.Mvc.FileResult'로 변환 할 수 없습니다." "" –