Showing posts with label providing. Show all posts
Showing posts with label providing. Show all posts

Friday, March 23, 2012

PDF always prompts

I'm publishing reports in PDF, providing users with URLs like
http://<server>/reportserver?/<reportname>&rs:Format=PDF&rs:Command=Render
In some circumstances, I'd like the PDF to open directly in the browser
without a prompt, but these always ask if I want to Open or Save the file,
directly in Acrobat Reader 8. How can I make this happen?
Static PDF files on my server open directly in the browser as expected.I had some fun trying to track that down too. I eventually found this, which
worked for me. I'm no expert so I'm not sure just what the critical bit is.
I'm using the Render method to get the report as a byte[] from Reporting
Services. Good luck:
private void DoOutput(byte[] result)
{
Response.ContentType = "Application/pdf";
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.BufferOutput = false;
int count = result.Length;
if (count > 0)
{
Response.OutputStream.Write(result, 0, count);
}
Response.End();
}
"Rocks" wrote:
> I'm publishing reports in PDF, providing users with URLs like
> http://<server>/reportserver?/<reportname>&rs:Format=PDF&rs:Command=Render
> In some circumstances, I'd like the PDF to open directly in the browser
> without a prompt, but these always ask if I want to Open or Save the file,
> directly in Acrobat Reader 8. How can I make this happen?
> Static PDF files on my server open directly in the browser as expected.|||So, I have to use ASP.NET? I'm still running classic ASP.
"jgwilliams" wrote:
> I had some fun trying to track that down too. I eventually found this, which
> worked for me. I'm no expert so I'm not sure just what the critical bit is.
> I'm using the Render method to get the report as a byte[] from Reporting
> Services. Good luck:
> private void DoOutput(byte[] result)
> {
> Response.ContentType = "Application/pdf";
> Response.Cache.SetCacheability(HttpCacheability.Public);
> Response.BufferOutput = false;
> int count = result.Length;
> if (count > 0)
> {
> Response.OutputStream.Write(result, 0, count);
> }
> Response.End();
> }
> "Rocks" wrote:
> > I'm publishing reports in PDF, providing users with URLs like
> > http://<server>/reportserver?/<reportname>&rs:Format=PDF&rs:Command=Render
> >
> > In some circumstances, I'd like the PDF to open directly in the browser
> > without a prompt, but these always ask if I want to Open or Save the file,
> > directly in Acrobat Reader 8. How can I make this happen?
> >
> > Static PDF files on my server open directly in the browser as expected.|||Aah, right. Sorry, I can't help you there - I never really used classic ASP
in earnest.
"Rocks" wrote:
> So, I have to use ASP.NET? I'm still running classic ASP.
> "jgwilliams" wrote:
> > I had some fun trying to track that down too. I eventually found this, which
> > worked for me. I'm no expert so I'm not sure just what the critical bit is.
> > I'm using the Render method to get the report as a byte[] from Reporting
> > Services. Good luck:
> >
> > private void DoOutput(byte[] result)
> > {
> > Response.ContentType = "Application/pdf";
> > Response.Cache.SetCacheability(HttpCacheability.Public);
> > Response.BufferOutput = false;
> > int count = result.Length;
> > if (count > 0)
> > {
> > Response.OutputStream.Write(result, 0, count);
> > }
> > Response.End();
> > }
> >
> > "Rocks" wrote:
> >
> > > I'm publishing reports in PDF, providing users with URLs like
> > > http://<server>/reportserver?/<reportname>&rs:Format=PDF&rs:Command=Render
> > >
> > > In some circumstances, I'd like the PDF to open directly in the browser
> > > without a prompt, but these always ask if I want to Open or Save the file,
> > > directly in Acrobat Reader 8. How can I make this happen?
> > >
> > > Static PDF files on my server open directly in the browser as expected.|||I found a solution that works for my situation, and even works in classic
ASP: just setup a server proxy:
Response.ContentType = "application/pdf"
reportSource = "reportserver?reportname&rs:Format=PDF"
set objReport = Server.CreateObject("MSXML2.ServerXMLHTTP")
objReport.open "GET", reportSource, false
objReport.send
Response.BinaryWrite(objReport.ResponseBody)
set objReport = nothing
"jgwilliams" wrote:
> Aah, right. Sorry, I can't help you there - I never really used classic ASP
> in earnest.
> "Rocks" wrote:
> > So, I have to use ASP.NET? I'm still running classic ASP.
> >
> > "jgwilliams" wrote:
> >
> > > I had some fun trying to track that down too. I eventually found this, which
> > > worked for me. I'm no expert so I'm not sure just what the critical bit is.
> > > I'm using the Render method to get the report as a byte[] from Reporting
> > > Services. Good luck:
> > >
> > > private void DoOutput(byte[] result)
> > > {
> > > Response.ContentType = "Application/pdf";
> > > Response.Cache.SetCacheability(HttpCacheability.Public);
> > > Response.BufferOutput = false;
> > > int count = result.Length;
> > > if (count > 0)
> > > {
> > > Response.OutputStream.Write(result, 0, count);
> > > }
> > > Response.End();
> > > }
> > >
> > > "Rocks" wrote:
> > >
> > > > I'm publishing reports in PDF, providing users with URLs like
> > > > http://<server>/reportserver?/<reportname>&rs:Format=PDF&rs:Command=Render
> > > >
> > > > In some circumstances, I'd like the PDF to open directly in the browser
> > > > without a prompt, but these always ask if I want to Open or Save the file,
> > > > directly in Acrobat Reader 8. How can I make this happen?
> > > >
> > > > Static PDF files on my server open directly in the browser as expected.|||I'm facing the same iissue, and would like to know how to use this method
"private void DoOutput(byte[] result)" the param result where i'm going to
fill it ?
thnx a lot
"jgwilliams" wrote:
> I had some fun trying to track that down too. I eventually found this, which
> worked for me. I'm no expert so I'm not sure just what the critical bit is.
> I'm using the Render method to get the report as a byte[] from Reporting
> Services. Good luck:
> private void DoOutput(byte[] result)
> {
> Response.ContentType = "Application/pdf";
> Response.Cache.SetCacheability(HttpCacheability.Public);
> Response.BufferOutput = false;
> int count = result.Length;
> if (count > 0)
> {
> Response.OutputStream.Write(result, 0, count);
> }
> Response.End();
> }
> "Rocks" wrote:
> > I'm publishing reports in PDF, providing users with URLs like
> > http://<server>/reportserver?/<reportname>&rs:Format=PDF&rs:Command=Render
> >
> > In some circumstances, I'd like the PDF to open directly in the browser
> > without a prompt, but these always ask if I want to Open or Save the file,
> > directly in Acrobat Reader 8. How can I make this happen?
> >
> > Static PDF files on my server open directly in the browser as expected.