开发者

Need to print a swf static images from my aspx component

I have a component in my application that show in my aspx page a x nurmbers of imagens get from my datasource of a repeater. I want to create a button and make this button print this images. I'd tried window.print() in my aspx开发者_运维问答, but it's only print the HTML information.


as far as i know, u can't print directly to the printer. u need to show the separate window with only img surrounded with div tag. here is the eample:

<%@ Page Language="C#" MasterPageFile="~/MasterPage2.master" AutoEventWireup="true" CodeFile="PrintImage.aspx.cs" Inherits="PrintImage" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
    <script language="javascript" type="text/javascript">
        function PrintImage()
        {
            printWindow = window.open ("", "mywindow", "location=1,status=1,scrollbars=1,width=600,height=600");
            printWindow.document.write("<div style='width:100%;'>");
            printWindow.document.write("<img id='img' src='" + document.getElementById('ctl00_MainContent_ImgMyPhoto').src + "'/>");
            printWindow.document.write("</div>");
            printWindow.document.close();
            printWindow.print();
        }
    </script>
    <div>
        <asp:Image ID="ImgMyPhoto" runat="server" Width="100px" Height="90px" />
        <br />
        <input type="button" id="btnPrint" value="Print Image" onclick="PrintImage()" />
    </div>
</asp:Content>

ref: this coding is get from Thirumalai_pm

Hope it works!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜