SQL varbinary提供的字节服务PDF [英] Byte Serving PDFs from SQL varbinary

查看:98
本文介绍了SQL varbinary提供的字节服务PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过允许用户一次下载一个页面来利用pdf的网络优化功能.

I am want to take advantage of the web optimization for pdfs by allowing users to download them a page at a time.

将pdf配置为可快速浏览Web. 我正在从sql server 2008提供pdf文件. c#.net 3.5 Web应用程序将linq转换为SQL,以将文件从数据库加载到二进制数组中. 该文件在IE客户端上的PDF阅读器插件中打开.

The pdfs are configured for fast web view. I am serving the pdfs from sql server 2008. The c# .net 3.5 web app untilises linq to SQL to load the files into a binary array from the database. The file is opended in PDF reader plugin on the client in IE.

任何帮助或正确方向上的推sho将不胜感激.

Any help or a shove in the right direction would be greatly appreciated.

谢谢

推荐答案

如果仅要将PDF发送给客户端,请使用以下代码创建一个aspx文件:

If you simply want to send a PDF to the client, create an aspx file with this code:

protected void Page_Load(object sender, EventArgs e)
{
  byte[] pdfdata = GetMyPdfDataSomehow();

  Response.Clear();
  Response.ContentType = "application/pdf";
  Response.BinaryWrite(pdfdata);

  if (NoCaching)
  {
    Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
  }
  else
  {
    Response.Cache.SetExpires(DateTime.Now.AddDays(7));
    Response.Cache.SetCacheability(HttpCacheability.Public);
    Response.Cache.SetValidUntilExpires(true);
  }
  Response.End();
}

但是,如果您想知道如何逐页拆分PDF文件,则需要一些PDF库.

However, if you want to know how to split the PDF file up page by page, you'll need some PDF library for that.

这篇关于SQL varbinary提供的字节服务PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆