我正在使用以下 ASP.NET 代码打开 PDF 文档,
Response.BufferOutput = true;
Response.Clear();
Response.ContentType = "application/pdf";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(documentURL);
using (HttpWebResponse responseDDRINT = (HttpWebResponse)request.GetResponse())
{
using (Stream stream = responseDDRINT.GetResponseStream())
{
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
int bytesRead;
while ((bytesRead = stream.Read(buffer, 0, bufferSize)) > 0)
{
Response.OutputStream.Write(buffer, 0, bytesRead);
}
Response.Flush();
}
}
我的问题是有人知道如何从特定页面开始呈现 PDF。例如,如果 PDF 文档有 15 页,我们希望它以最初显示的第 10 页打开,而不是在第 1 页打开。
我通过添加此标头尝试了“#page =”打开参数,但它什么也没做。
Response.AddHeader("content-disposition", "inline; filename=test.pdf#page=3");