Print Pdf File In Acrobat Reader Using Javascript And Close It?
Feb 23, 2010
we are displaying a reporting services report as a pdf document in acrobat reader. when the user clicks on the print in the acrobat reader, I will like to print the report and close the report. The user should be able to print the report only once.
I have been presented with a problem which requires me to print PDF files from a server as part of an ASP.NET web service.
The problem is further complicated by the fact that the PDF files I have to print can ONLY be printed using Adobe Reader (they were created using Adobe LiveCycle and have some strange protection in them).
This piece of code seems to do the trick in the Visual Studio development web server, but doesn't do anything when the site's running in IIS. I'm assuming this is probably some sort of permissions issue!?
Dim starter As ProcessStartInfo Dim Prc As Process ' Pass File Path And Arguments starter = New ProcessStartInfo("c:program files...AcroRd32.exe", "/t ""test.pdf"" ""Printer""") starter.CreateNoWindow = True starter.RedirectStandardOutput = True starter.UseShellExecute = False ' Start Adobe Process Prc = New Process() Prc.StartInfo = starter Prc.Start()
I'm getting "This SqlTransaction has completed; it is no longer usable" exception when try to commit my transaction after sqlreader is close.Here is the code sample
[Code]....
...so when I get to commit the transaction it raises the mentioned exception: "This SqlTransaction has completed; it is no longer usable". I have also noticet that Command.Transaction becomes NULL after reader.Close()My question is: Can I use SqlDataReader and SqlTransaction ? Maybe to use BeginExecuteReader and EndExecuteReader ?
I read the thread on this topic and tried using "Process.start(mypdf.pdf)" to open the PDF file. I was able to get "Process.Start()" to work perfectly within VS2008 on the built-in server but not IIS; when I am in the development environment it works great, but when I deploy the application and run it it does not work. What happens when I run outside of the development environment, I can export the PDF file to the directory on the IIS server, and the client can also delete the file from the IIS server, BUT, inbetween the export and the delete commands, I have the Process.start command so that the user can open the file and do whatever they need to do; print it, print partially or save it locally ect.
After it exports the file to the server when the exectue "Process.start" occurs, the screen just blinks and there is no error message? I tried many options using Process.StartInfo but no luck. I also tried to to use Process.Start() with a text file (.txt) and had the same result, so it doesn't look like an adobe acrobat problem. I do have acrobat running on the clients as well as the server. I don't think it is a security issue being the exporting and deleting work. Is this the wrong command to use? The web server is IIS7, I am using VS2008 VB.NET and it is a Web application. I need to demo this to the client in 4 days and I need to have this working.
I have some code in my vb.net code behind that queries a database, and if there is data, outputs it from the codebehind to a datalist on my asp.net page. In addition to sending the data to the datalist on the page, I need to take the value from "mbillaty" that is returned from the sql query, and have that value be the selected value for a drop down box also on the page. I can get either the datalist to fill, or the selected value for the dropdown box to be selected depending upon which bit of code I place before the other (ARGH), but I can't get them to both work together on the page. What am I doing wrong?
Everything seems to work, expect when I try to open the PDF file Adobe Reader says:
"Adobe reader could not open 'filename.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)."
I tried opening it in Adobe Photoshop and was not able to there either.
does anyone have any working code that uses javascript to open and close a cpe when the CPE is in a masterpage? It seems like the javascript never is able to find the CPE when it is on a master page. I have an DropDownList on the page and when certain items are selected, i want to collapse or expand when others are selected. It seems to work fine on a regular page, but not when it is a page nested in a master page. It is adding a suffix to the CPE and javascript is unable to find it.
In PageA, there is a button to open a crystal report. I want to add a HTML button into crystal report to close report(browser) and back to PageA. How to use javascript to do this job?
How can i use the acrobat driver to covert web page to pdf , i have a icon on my browser. How can i use that in ASP.NET to convert the web page to pdf pro grammatically.
I have a blog, where people can make comments. I've now decided to put the "writecomments.aspx" file in a Greybox popup-window. It works, but I want to close the window from codebehind (or javascript) after the comment is written. And then I want to refresh the blog page (the parent page) to show the new comment.
This is the code that opens the greybox (writecomments.aspx) page:
In the writecomments.aspx file, I just have 2 textboxes and 1 button (save-button). How can I make the greybox window close itself, and then somehow refresh the blog.aspx? Or maybe just a specific updatepanel for the current comments?
Edit
I got it working, I had to put this code in the codebehind, after the db-insert: Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "parent.parent.GB_hide();", true); And for the refresh of the parent page, I edited the gb_scripts.js file on line 12 from false to true: this.reload_on_close=true;
EDIT AGAIN
Actually, I modified it a bit, so, I put the gb_scripts.js file back to it's default state, and I just just the followig line of code in the WriteComments.aspx codebehind file, just after the db-insert:
2. button click event call th SQL stored procedure to save the form values
3. after save and get the output value from the SQL SP ( its boolean value)
4. if true i have to show the javascript alert or else nothing have to alert, so this is the code
if (CheckandBooked()) { ScriptManager.RegisterClientScriptBlock(btnBook, typeof(string), "alertscript", "alert('Selected time period clashes with existing booking');", true); } bug: this is working good but while showing the alert time i can see the calender( it look like design view) the design is adjusted how to avoid this
I am having an issue with displaying a PDF in an iframe in asp.net. When the pdf shows up it is showing up without the Acrobat toolbar that allows the user to zoom and print. This is causing a major hassle for our customers because they cannot read the PDF in the size that it is. If you try and set Acrobat to not show the PDF in the browser and browse to that page you get a message saying that it is trying to open it in Full Screen mode. how I can make it not do this from the code? Below is the code I use to stream the PDF to the browser:
Public Shared Sub StreamPdfToBrowser(ByVal doc As Document) Dim Ctx As HttpContext = HttpContext.Current '// Clear any part of this page that might have already been buffered for output. Ctx.Response.Clear() Ctx.Response.ClearHeaders() '// Tell the browser this is a PDF document so it will use an appropriate viewer. Ctx.Response.ContentType = doc.DisplayFileType Ctx.Response.ContentType = "application/pdf" Ctx.Response.AddHeader("content-type", "application/pdf") '// IE & Acrobat seam to require "content-disposition" header being in the response. If you don't add it, the doc still works most of the time, but not always. '// this makes a new window appear: Response.AddHeader("content-disposition","attachment[inline]; filename=MyPDF.PDF"); Ctx.Response.AddHeader("Content-Length", doc.DisplayFile.Length) Ctx.Response.AddHeader("Content-Disposition", "inline; filename=E-Sign Specification Report.pdf") '// TODO: Added by KN to possibly fix UA issue Ctx.Response.ContentType = "application/pdf" Ctx.Response.AddHeader("content-type", "application/pdf") '// Write the PDF stream out Ctx.Response.BinaryWrite(doc.DisplayFile) '// Send all buffered content to the client Ctx.Response.End()
In PageA, there is a button to open a crystal report. I want to add a HTML button into crystal report to close report(browser) and back to PageA. How to use javascript to do this job?
I have a popup window (aspx page) which is used to save log messages to the DB. I want to close this popup as soon as the user clicks the save button and the message has been saved into the database. My issue is the popup does not close when I use an UpdatePanel in conjunction with an UpdateProgress control.
Pages and Controls: ImplantQuoteInfo.aspx, ImplantQuoteRevisionLogMessageAdd.aspx, ImplantQuoteRevisionLogMessageAdd.ascx
ImplantQuoteInfo.aspx: This page creates the popup windows using RegisterStartupScript
[Code]....
ImplantQuoteRevisionLogMessageAdd.aspx: This page holds the user control with the funcitonality
ImplantQuoteRevisionLogMessageAdd.ascx: This user control takes a message text and saves it into the database. The control uses an HtmlEditor inside an UpdatePanel and an UpdateProgress control.
Markup:
[Code]....
C# code behind:
[Code]....
PS: I am using .NET framework 4.0, Windows 7, SQL 2008 R2.
I have a custom list earthquakes which contains a list of earthquakes. How do I parse this in JavaScript in order to add it to innerHtml and display on the screen. The problem is that I cannot get this to display on the screen in a div. When it parses I get no result because my javascript is wrong and if I try just printing the result i get [Object object]
So the flow goes input from textbox -> web service -> list to javascript
earthquakes class:
public class earthquakes { public string eqid { get; set; } public double magnitude { get; set; } public double lng { get; set; } public string source { get; set; } public DateTime date { get; set; } public int depth { get; set; } public double lat { get; set; } } dataEarthquakes class public class dataPostalCodes { public List<postalCodes> postalCodes { get; set; } }
WebService:
public static dataEarthQuakes getEarthquakes(dataPostalCodes postalCodes) { double lat = postalCodes.postalCodes[0].lat; double lng = postalCodes.postalCodes[0].lng; Uri address = new Uri(String.Format(FindEarthquakes, lat, 0, lng, 0)); WebClient client = new WebClient(); string jsonResponse = string.Empty; jsonResponse = client.DownloadString(address.AbsoluteUri); var results = JsonConvert.DeserializeObject<dataEarthQuakes>(jsonResponse); return results; }
Javascript:
function OnLookupComplete(e) { var result = e; var weatherData = new Sys.StringBuilder(); var line; for (var property in result.dataPostalCodes) { line = String.format("<b>{0}:</b> {1}<br/>", property, result.dataPostalCodes[property]); weatherData.append(line); } $get('divResult').innerHTML = weatherData.toString(); }
I have a page that has a note to the user about the file they're about to download and a button to click to start the download. When they click the button, it does a Response.Redirect to another page with the following code in its Page_Load:
I want the download to start and then I want this page (which is a tab in the browser) to close.
The code to download the file works fine. I just can't figure out how to close this tab when it's finished. I've read a lot of forum posts from people who are using similar code, but none of the suggestions seem to work for me. I understand that Response.End means that I can't put any more code this page; it will be ignored. But how do I get this tab to close?
I am using VS 2010 and C#. I am trying to create a pdf file in web application. I am trying to convert a dataset to pdf file. The pdf file is getting generated, but when i try to open the pdf, i am getting the error as "Adobe reader could not open "sample.pdf" because it is either not a supported file type or because the file has been damaged" How to fix this?