Print a webpart using javascript

Hi Team,
I have a requiremenrt to print my Sharepoint page content. The problem is I have a sharepoint aspx page which is being rendered inside a asp.net application. My Sharepoint page has a link button which shoul print only the content of sharepoint page from
the whole asp.net page being rendered on the browser. Any guidance would be helpful
I am using Sharepoint 2007
Regards ---------------------------------- Hemant Basavapattan(MCTS) Wipro Technologies

Place below code in content editor webpart.. Thanks http://www.bitsofsharepoint.com <SCRIPT language=javascript> function PrintPreview() { var sURL=document.location.href; if (sURL.indexOf('?') >0) { sURL=document.location+"&PrintPreview";} else { sURL=document.location+"?PrintPreview";}
window.open(sURL); } // If we are in Print Preview Mode then Hide a bunch of styles. if (document.location.href.indexOf('PrintPreview') >0) { document.write('<style>'); document.write('.pa-printicon, .jm-toolbar, .ms-navframe,.ms-bannerframe,.ms-sbtable,.ms-searchform,.ms-sbtopcorner,.ms-sblbcornerumb,.ms-globalbreadcrumb,.ms-pagetitleareaframe
table { display: none; } '); document.write('div.ms-titleareaframe { border-top: 0px white solid; } '); document.write('</style>'); print(); } </SCRIPT>
Click icon to Print Page:
Regards ---------------------------------- Hemant Basavapattan(MCTS) Wipro Technologies

Similar Messages

  • I want to display the print preview by using JavaScript.

    Can the print preview be displayed by using JavaScript?

    No, web pages doesn't have security rights to access most internal services of Firefox like Print Preview. A web page ''can'' access "Print" thru the operating system.

  • Pdf content not loading while printing using JavaScript

    In my web app, I am trying to print a doc using JavaScript, but content of the pdf is not getting loaded, this can be seen in the below link.
    https://drive.google.com/file/d/0B2nqjT-VxFWwVVhsQ1hLUnJ3MFU/view?usp=sharing
    Code:
    var printWin = window.open(this.lURL, '', 'top=100, left=500, width=900, height=800, titlebar=no');
    printWin.print();
    "this.lURL" is link which brings the pdf file/doc.
    Note: As soon as I click on cancel button of print, the content gets loaded.
    And if I click print blank page gets printed.

    ''guigs2 [[#answer-708101|said]]''
    <blockquote>
    I understand that the web app that your are developing has a function to print the contents of a pdf created with javascript, :
    Please first check these basic troubleshooting steps for printing:
    *[[Fix printing problems in Firefox]]
    Does this happen with the default pdf viewer or another?
    Next also check with stackoverflow.com:
    [https://support.mozilla.org/en-US/kb/where-go-developer-support Where to go for developer support]
    </blockquote>
    I want a solution which doesn't require to reset or change the settings of the browser.
    Once the app is available globally everyone should be able to use this functionality without altering the settings of the browser.

  • Printing different URL with javascript

    I am trying to print a URL using javascript but i do not want to print the current page. I have searched google, this forum and a javascript book and can not seem to figure it out. To exlplain in it generic terms i want to be on one page and tell it to print another. Reason being, I am looking at an overview page and want to print a report made in Oracle reports, (Yes I could load the report and print it but i want to print multiple reports from one button)(The reports do work and are valid) Here is a rundown of what I am doing.
    From a button i am calling a 'url' with the following code:
    javascript:V_PRINT('P50_CUSTOMER_ID','P50_YEAR');
    And then in the html header i have the code: (printing same page twice, just an example)
    <script language="JavaScript" type="text/javascript">
    function V_PRINT (formItem1,formItem2) {
    var formVal1 = document.getElementById(formItem1).value;
    var formVal2 = document.getElementById(formItem2).value;
    var url1;
    var url2;
    url1 = 'http://www.google.com/search?hl=en&q=' + formVal1 + '+' + formVal2;
    url2 = 'http://www.google.com/search?hl=en&q=' + formVal1 + '+' + formVal2;
    url1 = print();
    url2 = print();
    </script>
    This code just prints the current page. I know I am calling print incorrectly and thats where i need the help. Of course I might just be approaching it all wrong. Either way I hope someone with javascript knowledge can help.
    Thanks

    Hello,
    To print a page it has to be open in the browser since all it does it call the browsers print dialog.
    Here is one solution http://www.irt.org/script/508.htm and you can also try a iframe instead of a regular frame.
    If it's crossdomain request like your example here that might cause problems as well. There might be additional problems.
    Carl

  • Using Javascript to print and close window

    I found that I could open my document in a browser and using Javascript, automatically bring up a print dialog and send it to the printer. My problem is that this document opens in a browser that is being used as a kiosk touch screen with no address or navigation bar at the top (they are hidden).
    I would like to ave the pdf open in a new window, print and then close, making the original window viewable again. Is this possible?
    I have tried adding window.close() right after the print command, but it doesn't seem to work. Am I simply adding the close command incorrectly?
    var pp = this.getPrintParams();
    pp.interactive = pp.constants.interactionLevel.automatic;
    this.print(pp);
    window.close();

    This is what commands are allowed in Javascript for Mozilla Products. IF they haven't been touched by the user of the browser many of these are turned off by default.

  • How to change the print page setup in IE using javascript

    dear all,
    I want to take print out envelope paper size, so i want to chnage the page setup in IE
    i want to change the print page setup in IE using javascript

    I think, you can do this using CSS.
    http://support.sas.com/rnd/base/ods/templateFAQ/Template_csstyle.html

  • Open Print Dialog using JavaScript

    Hi folks, I'm trying to open dynamically the print dialog window for printing the PDF (Ctrl + P) in WebDynpro ABAP using JavaScript.
    The JavaScript seems to be executed only for Interactive Forms, however I don't need to use interactive but only Print-Based Forms.
    This line of code works if I assign it to an event like click for a button, I tried to call it in the doc:ready event but it does not work
    xfa.host.print(1, "0", "0", 0, 1, 0, 0, 0);
    Please I need some help and I hope it's possible!
    Alex

    Thanks, we are getting close!
    This line of code works, but it does not prompt me with the print dialog box (because of the first parameter is 0)
    xfa.host.print(0,"0","0", 0, 1, 0, 0, 1);
    I got this message box "This document is trying to print. Do you want to allow this?" Yes/No....
    Ok, that works but I would like to have the standard print dialog window instead, where you could select your printers.
    This line of code prompt me to save the XDP, this is not what I want
    xfa.host.exportData("",1);
    In which event should I place the script??
    Also, script only seems to be executed for interactive forms, I don't want to generate interactive forms, they are more heavy to render, this is only for print based forms!
    thanks
    Alexandre Giguere

  • How to use javascript to print on the client side

    hi all,
    Now i'm facing a problem:
    I want to use javascript to print something(for example, a table) on the client side. So i must get a connection with the printer installed in the client computer.
    some says that getObject() function can do this,but i don't know how?
    Who please help me!

    window.print();

  • Print PDFs from Dreamweaver using Javascript

    I need to print several PDF'S from a coldfusion application.
    I understand that you can use Javascript if you need to print
    several pdfs in sequence. Do you know of a script that will
    print several documents ?

    When you select print from the menu bar a print
    window opens. Verify that the correct printer is
    selected. Adobe will over ride some defaults and put
    in itself. Let me know if this didn't work.
    Thanks Glynn, but the correct printer is indeed selected. This is a weird one!
    FWIW, here is my CUPS error log:
    ===== Wednesday, June 20, 2007 3:51:51 PM US/Eastern =====
    I [20/Jun/2007:15:52:20 -0400] Adding start banner page "none" to job 10.
    I [20/Jun/2007:15:52:20 -0400] Adding end banner page "none" to job 10.
    I [20/Jun/2007:15:52:20 -0400] Job 10 queued on 'MFC_9420CN' by 'dave'.
    I [20/Jun/2007:15:52:20 -0400] Started filter /usr/libexec/cups/filter/pictwpstops (PID 625) for job 10.
    I [20/Jun/2007:15:52:20 -0400] Started filter /usr/libexec/cups/filter/pstocupsraster (PID 626) for job 10.
    I [20/Jun/2007:15:52:20 -0400] Started filter /Library/Printers/Brother/Filter/rastertobrotherSL4C (PID 627) for job 10.
    I [20/Jun/2007:15:52:20 -0400] Started backend /usr/libexec/cups/backend/usb (PID 628) for job 10.
    E [20/Jun/2007:15:52:22 -0400] [Job 10] pstopdffilter/pstocupsraster failed with err number -31000
    E [20/Jun/2007:15:52:22 -0400] PID 627 stopped with status 1!
    I [20/Jun/2007:15:52:22 -0400] Hint: Try setting the LogLevel to "debug" to find out more.
    E [20/Jun/2007:15:52:22 -0400] PID 625 stopped with status 1!
    I [20/Jun/2007:15:52:22 -0400] Hint: Try setting the LogLevel to "debug" to find out more.
    E [20/Jun/2007:15:52:22 -0400] [Job 10] Opening raster file failed!
    E [20/Jun/2007:15:52:22 -0400] [Job 10] error drawing page 1
    E [20/Jun/2007:15:52:22 -0400] [Job 10] pictwpstops - got an error disposing of document = -9783
    E [20/Jun/2007:15:52:22 -0400] PID 626 stopped with status 1!
    I [20/Jun/2007:15:52:22 -0400] Hint: Try setting the LogLevel to "debug" to find out more.

  • How to get page number from the PDF using Javascript

    Hi,
    We are having list of Single page PDF. The pdf are named in the order,
    ISBN_Author_01.PDF  (with real page number as i)
    ISBN_Author_02.PDF  (with real page number as ii)
    ISBN_Author_03.PDF  (with real page number as iii)
    ISBN_Author_04.PDF  (with real page number as 1)
    ISBN_Author_05.PDF  (with real page number as 2)
    ISBN_Author_06.PDF  (with real page number as 3)
    ISBN_Author_nn.PDF  (with real page number as 500)
    Here each pdf has a page number and in sequential order.
    The task is to check whether all the pdfs are in sequential order (i.e i, ii, iii, 1, 2, 3). If any page is missing, the script should throw an error report.
    To do this task, I am writing a Javascript to get the real page number from the PDF.
    Can anybody help me how to get the page number from the PDF using Javascript.
    Thanks,
    Gopal

    The "real" page number within a PDF is the count of the physical page starting at 0, zero.
    pageNum numPages
    The number printed on each page is the page label.
    setPageLabels  getPageLabel
    You will have to open each PDF and your script would need to know the page label for that file. I would expect you would need to build a 2 dimensional  array of the file names and the page label for the page within that array.

  • How to Hide some Rows in a List view Web Part using JavaScript ?

    How to Hide some Rows in a List view Web Part using JavaScript ?

     Here is the code that worked for me:
    var Elements = document.querySelectorAll('div[id=WebPartWPQ3] table[class=ms-listviewtable]>tbody tr .ms-vb-lastCell.ms-cellstyle.ms-vb2')
    for(var i=0, n = Elements.length; i < n; i++)
     if(Elements[i].innerHTML=="India")
    Elements[i].parentNode.setAttribute("style","display:none")
    WebPartWPQ3 -> ID of webpart Div
    ms-listviewtable -> class name of table in Div
    ms-vb-lastCell.ms-cellstyle.ms-vb2 -> classname of td to get text

  • Print PDF file using Acrobat SDK - Warning message

    Hello,
    We are trying to create automatic program in c# that will print all pdf files located in a specific folder, using Adobe Acrobat 9.0 SDK.
    Whenever the application tries to print file, we receive a warning message ("WARNING! A script has requested to print an Acrobat file. This could print an entire document. Do you want to proceed printing?").
    If we press yes, the file is printed, but next time we'll run the application, this message will appear again.
    Since this application supposed to run automatically (with no interaction with the end users), we want to prevent this warning message from appearing.
    How can we eliminate this warning message?
    Is there any other way to print PDF files using Adobe Acrobat from another application?
    Thanks,
    Lilach.

    joeln3:  I believe the original post refers to a client application, not a web page.  Why use JavaScript from within a client application?  I understood their use case to involve a client app referencing the PDF Library, loading various PDF files, and using one (or more) of the PDF Library's Print methods to invoke Acrobat's internal print routines.
    Dave

  • When I print to PDF using Acrobat 11 Pro from any application the acrobat Reader does not launch automatically. Associations are correct. Thx for your help,  Bruce

    When I print to PDF using Acrobat 11 Pro from any application the acrobat Reader does not launch automatically. Associations are correct. Happens from Chrome, IE, Word, Excel, Powerpoint. Previously had deskPDF installed but uninstalled correctly. Can't find a preference setting for the auto launch. Thx for your help,  Bruce

    A simple way is to flatten the form fields, which converts the field appearances to regular page contents. You can do this with JavaScript or PDF Optimizer (Advanced > PDF Optimizer > Discard Objects > Flatten form fields). A very nice script that adds a custom menu item can be found here: http://www.uvsar.com/projects/acrobat/flattener/

  • How to validate People Picket control at client side using javascript/Designer in New form.aspx

    Hi Folks,
    I have list library with 2 columns. where as 1 column is people picker control and it is not mandatory filed .
    When the user open newform.aspx and fill all the column values and submit it should show error message if user not enter any data in people picker control column though it is not a mandatory column.
    How to achieve this by using javascript or sharpoint designer.

    Hello,
    Here is script for that:
    http://social.msdn.microsoft.com/Forums/en-US/f1c2a651-a0fb-484d-af33-e7084439b6c8/validate-sharepoint-people-picker-using-javascript?forum=sharepointgeneralprevious
    http://ankursharepoint.blogspot.in/2012/10/javascript-validation-of-people-picker.html
    Edit your newform.aspx page and add content editor webpart on that page. Then add script on HTML source section.
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Using Javascript to disable field "Planned"

    Hi every one,
    I want to use javascript to disable "Planned" checkbox in Project Server 2013 because we want that user can not see this planned time and be confused with the Project Server's automatic changes for the planned time.
    <script type="text/javascript">
    document.getElementById("Ribbon.ContextualTabs.MyWork.Home.ShowHide.PlannedWork-Medium-checkbox").checked = false;
    </script>
    I found this code in this subject :
    http://social.technet.microsoft.com/Forums/projectserver/en-US/0beeed2d-bebc-4217-981a-41b1252c7cc2/disable-field-planned-in-timesheet?forum=projectserver2010general
    But I don't understand where to use it. If i create a custom webpart with this code, I've got a null exception when the page is loading.
    So, can you help me ? Maybe I need to use it in an other file ?

    Hi Patmol6,
    Basically, to add javascript to a PDP (or timesheet page for instance), 
    edit the page
    add the content editor webpart
    set it as hidden
    copy paste the code
    Note that you can also point from the content editor webpart to a js file embedding the javascript code
    Here are few examples (some are in PS2007, but the process is similar): 
    http://epmsource.com/tag/content-editor-webpart/
    http://badalratra.wordpress.com/2013/05/04/how-to-disable-pdp-custom-fields-using-javascript/
    http://badalratra.wordpress.com/2013/02/03/javascript-code-to-add-custom-descriptions-underneath-project-field-on-the-pdp-page/
    http://epmcorner.wordpress.com/tag/content-editor-web-part/
    Hope this helps.
    Guillaume Rouyre - MBA, MCP, MCTS

Maybe you are looking for