iFrame preview and printing

The free basic subset of ScriptX includes the printing of the content of an iFrame but does not include the ability to preview the content.


Licensed ScriptX includes the ability to preview the content to be printed from an iFrame.

 

Implementation

Here, we place the ScriptX objects on the document that contains the iFrame (in the next sample we will place the ScriptX object in the frame to be previewed / printed).

To print or preview an iframe we simply pass the name of the frame to the Print() or Preview() functions.

jQuery

For example, including using the  MeadCo ScriptX javascript helper library the following script can be used to attach appropriate event handlers to elements on the page:

$("#btn-print").click(function() { 
    MeadCo.ScriptX.PrintFrame("infoframe", false); 
});
            
$("#btn-preview").click(function() { 
    MeadCo.ScriptX.PreviewFrame("infoframe"); 
});
            

Helper library

Or, for example using the  MeadCo ScriptX Helpers for ASP.NET MVC package the buttons and script are generated:

@MeadCo.ScriptXClient.PrintButton.GetHtml(frame:"infoframe",
                htmlAttributes:new { @class="btn btn-default"})
            
@MeadCo.ScriptXClient.PrintPreviewButton.GetHtml(frame: "infoframe", 
                htmlAttributes: new { @class = "btn btn-primary" })