Printing an Image embedded into an asp.net page. C#

Posted by user1683846 on Stack Overflow See other posts from Stack Overflow or by user1683846
Published on 2012-09-25T15:49:28Z Indexed on 2012/09/25 21:37 UTC
Read the original article Hit count: 142

Filed under:
|

I am looking to print using C#, micorsoft 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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about printing