है
मैंने उपरोक्त सभी समाधानों का प्रयास किया और उनमें से कोई भी मेरे लिए काम नहीं करता, मैं एमवीसी 3 के शीर्ष पर जावास्क्रिप्ट चला रहा हूं, और रेज़र, एडोब 11 यानी क्रोम और फ़ायरफ़ॉक्स पर एड-ऑन के रूप में स्थापित है। यह सब कुछ है जो मैंने उपर्युक्त ब्राउज़रों पर काम करने के लिए किया था।
मेड पीडीएफ नियंत्रक, मुख्य दृश्य के लिए रेजर कोड में इस
तरह जावास्क्रिप्ट से कहा जाता है:
var URL_OPEN_REPORT_PDF = "@Url.Content("~/Report/OpenPDF/")";
जावास्क्रिप्ट:
var sURL = URL_OPEN_REPORT_PDF;
sURL = AddURLParameter(sURL, "ReportArchive", moControl.treeOrganization.getUserData(sItemUI, "reportarchive"));
window.open(sURL);
नियंत्रक ReportController.cs:
[Authorize]
[HttpGet]
public ActionResult OpenPDF(string ReportArchive)
{
PDFResult oPdfResult = new PDFResult();
ReportArchive oReportArchive;
var serializer = new JavaScriptSerializer();
oReportArchive = serializer.Deserialize<ReportArchive>(ReportArchive);
string FilePath = Server.MapPath(string.Format("~/Content/Reports/{0}", oReportArchive.FileName));
WebClient User = new WebClient();
Byte[] FileBuffer = User.DownloadData(FilePath);
if (FileBuffer != null)
{
oPdfResult.Length = FileBuffer.LongLength;
oPdfResult.FileBuffer = FileBuffer;
Response.BinaryWrite(FileBuffer);
} return View("PDF", oPdfResult);
}
ViewModel PDFResult.cs:
public class PDFResult
{
/// <summary>
/// Content Length
/// </summary>
public long Length { get; set; }
/// <summary>
/// Content bytes
/// </summary>
public Byte[] FileBuffer { get; set; }
}
देखें PDF.cshtml:
@model Report.PDFResult
@{
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", Model.Length.ToString());
Layout = null;
}