Implementation of printing law enforcement documents (iv): Calling ie printing preview and document printing Preview

Source: Internet
Author: User

Implementation of printing law enforcement documents (iv): Calling ie printing preview and document printing Preview

Implementation of printing law enforcement documents (iv): Calling ie printing Preview

I was a little discouraged when my previous blog was removed from the home page. These blogs may not work hard, but only serve as a task. In the future, there will be candidates for low quality. We need to be conscious. This article is finally finished, so happy.

The document page is implemented by rendering static html to the div of this page. Calling ie print preview directly on this page will not enable automatic paging or control of the Print Style.

Page div: <div id = "htmlContainer" align = "center"> </div>

Html Rendering:

Function renderHtml (){

Var htmlCfg = {

Url: htmlUrl, // static html address

Success: loadHtml, // operations successfully executed by requesting html

Async: true

};

 

$. Ajax (htmlCfg );

}

// Render the form content and data to the div

Function loadHtml (data, textStatus ){

// Add a cloud form

// Alert (data );

$ ("# HtmlContainer"). append (data );

// Initialization after the cloud form is loaded

CForm. init ();

// Submit a single form

RenderForm ();

}

To achieve better print preview, call the print preview method on the opener page:

How to print the preview button on this page:

Function pre_print (){

// TabPanel. activeTab. id. split ("_") [0] Get the divID of the current activity and pass it as a parameter to the pre-print.jsp

Var url = L5.webPath + "/jsp/aaepcform/cfaaepformapply/render/pre-print-s.jsp? CurrentWId = htmlContainer & formId = "+ formId;

Ow = window. open (url, 'print instruments ', 'height = 1100, width = 800, toolbar = no, menubar = no, scrollbars = 2, resizable = no, location = no, status = no, alwaysRaised = yes, z-look = yes, depended = yes ');

}

}

Read the Form Content in the div on this page in the opener window:

// Div element to be printed

Var elasticsearch extends opener.doc ument. getElementById (currentWId );

// Copy the printed content to the div on this page

$ ("Body"). append (el. innerHTML );

Call print preview:

Var HKEY_Root, HKEY_Path, HKEY_Key;

HKEY_Root = "HKEY_CURRENT_USER ";

HKEY_Path = "\ Software \ Microsoft \ Internet Explorer \ PageSetup \\";

// Print settings: by modifying the Registry

Function doPrintPreview (){

Try {

// Registry operation object

Var RegWsh = new ActiveXObject ("WScript. Shell ");

// Set the header to null

HKEY_Key = "header ";

RegWsh. RegWrite (HKEY_Root + HKEY_Path + HKEY_Key ,"");

// Set the footer to null

HKEY_Key = "footer ";

RegWsh. RegWrite (HKEY_Root + HKEY_Path + HKEY_Key ,"");

// Set the bottom margin to 0.

HKEY_Key = "margin_bottom ";

RegWsh. RegWrite (HKEY_Root + HKEY_Path + HKEY_Key, "0 ");

// Set the left margin (0)

HKEY_Key = "margin_left ";

RegWsh. RegWrite (HKEY_Root + HKEY_Path + HKEY_Key, "0 ");

// Set the right margin (0)

HKEY_Key = "margin_right ";

RegWsh. RegWrite (HKEY_Root + HKEY_Path + HKEY_Key, "0 ");

 

// Set the top margin to 0

HKEY_Key = "margin_top ";

RegWsh. RegWrite (HKEY_Root + HKEY_Path + HKEY_Key, "0 ");

 

// Set not to shrink to the paper size. The default value is 100%.

HKEY_Key = "Shrink_To_Fit ";

RegWsh. RegWrite (HKEY_Root + HKEY_Path + HKEY_Key, "no ");

// Set the print page background

HKEY_Key = "Print_Background ";

RegWsh. RegWrite (HKEY_Root + HKEY_Path + HKEY_Key, "yes ");

 

// Call the ie component to print and preview

PrintWB. ExecWB (7,1 );

} Catch (e ){

Alert ("Printing failed, Please modify IE Security Settings ");

};

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.