只打印图像,嵌入到ASP.NET页面 [英] Printing only the Image, embedded into an ASP.NET page

查看:125
本文介绍了只打印图像,嵌入到ASP.NET页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找使用C#,微软的Visual Studio,asp.net打印。

目标:我想打印传真文档中的所有页面

格式:传真文件接收与多页的单个文件.TIFF

需要采取哪些措施: - 我需要遍历每个页面.TIFF图像并打印他们全部

  //此函数会遍历所有页面,一次一个。 // 保护无效PrintAll_Click(对象发件人,EventArgs的发送)
 {
    //计数在传真document.//页数
    INT数= _FaxPages.Count;    // for循环通过每个页面进行迭代。 //
    的for(int i = 0; I<数;我++)
    {
        字符串_FaxId = Page.Request [FaxId];        _PageIndex = I;        imgFax.ImageUrl =?ShowFax.ashx N =+ _FaxId +&放大器; F =+ _PageIndex +&放大器; MW = 750;        PrintAll.Attributes.Add(的onclick,返回打印());
    }
}

在我的Java脚本的我有:

 打印功能(){window.print(); }

现在的问题是:


  1. 该功能只打印一页(TIFF文件的最后页)......并打印整个窗口,而不只是在整个Web浏览器窗口嵌入.TIFF图像。

    任何想法如何去只是打印.TIFF嵌入图像而非整个网页浏览器窗口。


  2. 虽然通过网页我的for循环迭代。循环经历的所有网页迭代并停止在最后一页后打印功能只调用(6/6说页)。然后只打印了最后一页(有内容的浏览器窗口上的其余部分一起)。这不是我希望发生的事情......我不想打印所有多余的材料在浏览器窗口,如按钮,链接等...我只是想从浏览器窗口中嵌入.TIFF图像。



解决方案

通过在服务器端的所有页面您当前的code将循环和更新图片的网址,发送页面到客户端之前。这意味着的ImageUrl 将永远是你的最后一页而已。

有关打印所有图像,有多种解决方案:


  • 编辑你的 ShowFax.ashx ,添加一个选项来呈现一次的传真页,并把这个在图像URL。

  • 添加一个新的图片元素为每个页面父容器在运行时。

  • 有javascript函数打印()做回发,增加图像的页面索引和URL,并重复code。

  • 创建整个循环客户方。

有关打印只有图像,隐藏与CSS样式表的其他元素,并添加媒体=打印是这样的:

 <链接rel =stylesheet属性类型=文/ CSS媒体=打印HREF =print.css/>

I am looking to print using C#, Microsoft Visual Studio, asp.net.

The goal: I am trying to print all pages in a fax document.

Format: The fax document is received as a single .tiff file with multiple pages.

What needs to be done:- I need to iterate each page in the .tiff image and print them all.

// This function will iterate all pages, one at a time. //

 protected void PrintAll_Click(object sender, EventArgs e)
 {
    // counts number of pages in the fax document.//
    int number = _FaxPages.Count;

    // for loop to iterate through each page. //
    for (int i = 0; i < number; i++)
    {
        string _FaxId = Page.Request["FaxId"];

        _PageIndex = i;

        imgFax.ImageUrl = "ShowFax.ashx?n=" + _FaxId + "&f=" + _PageIndex + "&mw=750";

        PrintAll.Attributes.Add("onclick", "return printing()");             
    }
}

and In my Java script I have:

function printing() { window.print(); }

Now the issues are:

  1. The function only prints one page (the very last page of the tiff file)....and it prints the entire window and not just the embedded .tiff image in the entire web browser window.

    Any Ideas of how to go about just printing the .tiff embedded image instead of the entire web browser window.

  2. Although my for loop iterates through the pages. The print function is only called after the loop has iterated through all the pages and stopped on the final page (say page 6/6). And then it only prints that last page (along with the rest of the contents on the browser window). This is not what I want to happen... I dont want to print all the excess material on the browser window such as buttons, links etc... I just want the embedded .tiff image from the browser window.

解决方案

Your current code will loop through all pages on the server side and update the image URL, before sending the page to the client. This means the ImageUrl will always be your last page only.

For printing all the images, there are multiple solutions:

  • Edit your ShowFax.ashx, add an option to render all fax pages at once and put this in the image URL.
  • Add a new Image element for each page to a parent container at runtime.
  • Have the javascript function printing() do a postback, increase the page index and the URL on the image and repeat the code.
  • Create the entire loop clientside.

For printing only the image, hide the other elements with a CSS stylesheet and add a media="print" like this:

<link rel="stylesheet" type="text/css" media="print" href="print.css" />

这篇关于只打印图像,嵌入到ASP.NET页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆