Open a "Generated" PDF

K

Kuldeep

Framework: Visual Studio 2005
Technology: ASP.NET 2.0
Language: C#.NET 2.0

Hi All,

I have an in-built tool to generate PDF Reports.
Once a PDF Report is generated, I have provided an option of "Viewing" the
PDF as well.
Now, once there is a large PDF being generated (say a PDF of 70 Pages or so)
and I try to "View" the PDF then it fails to do so.
The reason being, my code is actually trying to view a PDF File which is
still in the "building" stage and not a completely "built" PDF.

How do I programmatically put a delay into my code so that the process of
"Viewing" the PDF doesnot hang and show the PDF file successfully.

Here is what I have at present to "View" the PDF.
protected void lnkViewPdf_Click(object sender, EventArgs e)

{

string jScript;

jScript = "<script>window.open('" +
Request.ApplicationPath.ToString().ToLower() + stringPDFUrl +
"','','','')</script>";

Page.RegisterClientScriptBlock("keyClientBlock", jScript);

lnkViewPdf.Visible = false;

}

Please help me how would I tweak the code so that there is a delay while
"Viewing the PDF" just after the PDF is generated.

Any leads on this would be very helpful.

Thanks in advance,
Kuldeep
 
B

bruce barker

instead of opening the pdf directly, open an asp.net page that delays
until the pdf is built then redirects to it. if the wait is very long
(over a second or two), have the page do a meta refresh and display a
working... gif.


-- bruce (sqlwork.com)
 
M

Mark Rae

I have an in-built tool to generate PDF Reports.
Once a PDF Report is generated, I have provided an option of "Viewing" the
PDF as well.
Now, once there is a large PDF being generated (say a PDF of 70 Pages or
so) and I try to "View" the PDF then it fails to do so.
The reason being, my code is actually trying to view a PDF File which is
still in the "building" stage and not a completely "built" PDF.

How do I programmatically put a delay into my code so that the process of
"Viewing" the PDF doesnot hang and show the PDF file successfully.

I've had similar issues in the past...

Does your PDF generation tool return a value when it finishes? How are you
calling it? Can it be configured to create a zero-byte file after it's
created the PDF?
jScript = "<script>window.open('" +
Request.ApplicationPath.ToString().ToLower() + stringPDFUrl +
"','','','')</script>";

Page.RegisterClientScriptBlock("keyClientBlock", jScript);

Also, since you're using ASP.NET 2, you should be using
ClientScript.RegisterClientScriptBlock, as Page.RegisterClientScriptBlock is
now obsolete:
http://msdn2.microsoft.com/en-us/library/system.web.ui.page.registerclientscriptblock(VS.71).aspx
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=15280&SiteID=1

In addition, that has an additional boolean argument which you can set to
true so that it creates the <script> tags automatically...

If want to continue with the obsolete class, consider changing the first
line of the JavaScript to:
jScript = "<script type="text/javascript">window.open('" +

so that at least your code is standards compliant...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,108
Latest member
AlbertEste
Top