MVC Web アプリケーションであり、ファイルがサーバー上に存在するため、文字列 base64 要素として返す pdf 要素があります。現在、PDFObject と pdf.js を使用して、この PDF をブラウザーで表示しようとしています。ただし、このアプリケーションをサーバー上の IIS に配置すると機能しない URL を渡さない限り、PDF を表示できないようです。
src="{my base 64 string} を埋め込んだ PDF を作成し、その周りに PDFObject をラップする方法はありますか?そうでない場合は、PDFObject を介して、url の代わりに base64 文字列を使用する方法はありますか? ?
また、これはIE 11にあります
更新 これが私のコントローラーです
public ActionResult GetPDFString(string instrumentType, string booktype, string book, string startpage, string EndPage)
{
LRS_Settings settings = ctxLRS.LRS_Settings.FirstOrDefault();
string root = settings.ImagePathRoot;
string state = settings.State;
string county = settings.County;
g_filePath = @"\\10.20.170.200\Imaging\GA\075\Daily\" + instrumentType + "\\" + book + "\\";
//g_filePath = @"\\10.15.100.225\sup_court\Imaging\GA\075\Daily\" + instrumentType + "\\" + book + "\\";
byte[] file = imgConv.ConvertTifToPDF(g_filePath, booktype, book, startpage, EndPage);
var ms = new MemoryStream(file);
var fsResult = new FileStreamResult(ms, "application/pdfContent");
return fsResult;
//return imgConv.ConvertTifToPDF(g_filePath, booktype, book, startpage, EndPage);
}
ここに私のjqueryがあります
var options = {
pdfOpenParams: {
navpanes: 1,
toolbar: 0,
statusbar: 0,
pagemode: 'none',
pagemode: "none",
page: 1,
zoom: "page-width",
enableHandToolOnLoad: true
},
forcePDFJS: true,
PDFJS_URL: "/PDF.js/web/viewer.html"
}
PDFObject.embed("@Url.Action("GetPDFString", "DocumentView", new { instrumentType = ViewBag.instrumentType, BookType = Model.BookType, Book = ViewBag.Book, StartPage = ViewBag.StartPage, EndPage = ViewBag.endPage, style = "height:100%; width100%;" })", "#PDFViewer", options);
問題は、#PDFViewer 内に PDF を表示する代わりに、ファイルをダウンロードしようとしていることです。誰かパズルの最後のピースを手伝ってくれませんか。これは私を夢中にさせています。