By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,724 Members | 859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,724 IT Pros & Developers. It's quick & easy.

Open a "Generated" PDF

P: n/a
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
Jun 14 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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)
Kuldeep wrote:
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

Jun 14 '07 #2

P: n/a
"Kuldeep" <ku****************@hotmail.comwrote in message
news:ub**************@TK2MSFTNGP06.phx.gbl...
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/lib...ck(VS.71).aspx
http://forums.microsoft.com/msdn/Sho...15280&SiteID=1

In addition, that has an additional boolean argument which you can set to
true so that it creates the <scripttags 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...
--
http://www.markrae.net

Jun 14 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.