没有Acrobat Reader的Asp.net PDF文件视图 [英] Asp.net with PDF file view without Acrobat Reader
本文介绍了没有Acrobat Reader的Asp.net PDF文件视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个asp.net应用程序,我只想查看我已经存储在网站物理路径中的Pdf。现在我想在没有安装Adobe Reader的情况下查看pdf。
请给我一个简单的解决方案
在此先感谢: - )
I have an asp.net application, I just want to view the Pdf that i have alreay stored in physical path of a website. Now I want to view the pdf without Adobe Reader installed PC.
Please give me simple solution for it
Thanks in Advance:-)
推荐答案
你好,
看看Mozilla的PDF.js
http://mozilla.github.io/pdf .js / [ ^ ]
这是一个非常简单的例子:
https://github.com/mozilla/pdf.js/tree/master/examples/helloworld [ ^ ]
Hello,
Have a look at PDF.js from Mozilla
http://mozilla.github.io/pdf.js/[^]
And here is a very simple example:
https://github.com/mozilla/pdf.js/tree/master/examples/helloworld[^]
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
//
// See README for overview
//
'use strict';
//
// Fetch the PDF document from the URL using promises
//
PDFJS.getDocument('helloworld.pdf').then(function(pdf) {
// Using promise to fetch the page
pdf.getPage(1).then(function(page) {
var scale = 1.5;
var viewport = page.getViewport(scale);
//
// Prepare canvas using PDF page dimensions
//
var canvas = document.getElementById('the-canvas');
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
//
// Render PDF page into canvas context
//
var renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
});
});
Valery。
Valery.
您可以通过iframe使用Google Doc Viewer并指定要显示的PDF文件。这是你应该添加的代码:
You could use Google Doc Viewer through an iframe and specify the PDF file you want to display. This is the code you should add:
<iframe src="http://docs.google.com/gview?url=YOUR_ABSOLUTE_URL_TO_THE_PDF_FILE_HERE&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
然后你只需要将自己的文档文件设置为url查询字符串para m就是这样!
Then you just need to set up your own document file to the "url" query string param and that's it!
byte[] bts = System.IO.File.ReadAllBytes(filename);
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.WriteFile(filename);
Response.Flush();
Response.End();
这篇关于没有Acrobat Reader的Asp.net PDF文件视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文