By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,016 Members | 2,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,016 IT Pros & Developers. It's quick & easy.

Print multiple files continuously...

P: 4
Hi All,

In my application(Web application) I need to Print more than one page one by one without giving next to Print.... That is In my application, Lots of files shows with their Name in Gridview with multiple selection option with check box. If i click only one check box then, it works fine to print. But I need to Print more than one file. That is I selected many files by checking that check boxes. then second file is automatically prints when printed the first file without giving any event thru button.... Is it possible.. Please guide me on this.....


Thanks,
Sarav
Jan 19 '09 #1
Share this Question
Share on Google+
5 Replies


Frinavale
Expert Mod 5K+
P: 9,731
How are you printing files?
Are you using JavaScript to print to a client's computer, or are you printing on the Server?
Jan 19 '09 #2

P: 4
I tried it from javascript.

Window.Print();
Jan 20 '09 #3

Frinavale
Expert Mod 5K+
P: 9,731
You're either going to have to call the Window.Print() method for each selected file or you can append the selected files onto the first file and just print one file.

You should look into how CSS can help you format your printed content.
Jan 20 '09 #4

P: 4
Hi.,

Herewith I have given the Code which I was used...

Expand|Select|Wrap|Line Numbers
  1.  divPrint.Visible = false;
  2.         int i;
  3.         for (i = 0; i < count; i++)
  4.         {
  5.             string cid = strSplitArr[count-1].ToString();
  6.             Correspondence_ID = Convert.ToInt32(cid);
  7.             dsCorrespondence = objBOCorrespondence.LetterDetails(Correspondence_ID);
  8.             if (dsCorrespondence.Tables[0].Rows.Count > 0)
  9.             {
  10.                 lblName.Text = dsCorrespondence.Tables[0].Rows[0]["UserName"].ToString();
  11.                 lblAddress1.Text = dsCorrespondence.Tables[0].Rows[0]["PersentAddress1"].ToString();
  12.                 lblAddress2.Text = dsCorrespondence.Tables[0].Rows[0]["PersentAddress2"].ToString();
  13.                 lblVillage.Text = dsCorrespondence.Tables[0].Rows[0]["PresentVillage"].ToString();
  14.                 lblIsland.Text = dsCorrespondence.Tables[0].Rows[0]["IslandName"].ToString()+','+dsCorrespondence.Tables[0].Rows[0]["PersentZipcode"].ToString();
  15.                 //lblZipcode.Text = dsCorrespondence.Tables[0].Rows[0]["PersentZipcode"].ToString();
  16.                 lblSubject.Text = dsCorrespondence.Tables[0].Rows[0]["TemplateName"].ToString();
  17.                 lblFirstName.Text = dsCorrespondence.Tables[0].Rows[0]["FirstName"].ToString() + ",";
  18.                 lblLetterTitle.Text = dsCorrespondence.Tables[0].Rows[0]["LetterTitle"].ToString();
  19.                 lblLetterDescription.Text = dsCorrespondence.Tables[0].Rows[0]["LetterDescription"].ToString();
  20.                 lblDate.Text = (DateTime.Today.Date.ToShortDateString());
  21.                 divLetter.Visible = true;
  22.                 //StringBuilder sb = new StringBuilder();
  23.                 //sb.Append("<script type=\"text/javascript\">");
  24.                 //sb.Append("window.open('ViewLetter.aspx?val=" + "','','height=850,width=750')");
  25.                 //sb.Append("</script>");
  26.                 count = count - 1;
  27.                 Session["val"] = count;
  28.                 StringBuilder objStr1 = new StringBuilder();
  29.                 objStr1.Append("<script language='javascript'>");
  30.                 objStr1.Append("printseleteditems();");
  31.                 objStr1.Append("</script>");
  32.                 LtPrint.Text = objStr1.ToString().Trim();
  33.                 divPrint.Visible = true;
  34.                 return;
  35.                 //LtPrint.Text = sb.ToString();
  36.             }
  37.             else
  38.             {
  39.                 PSResource.PSResourceName = "PS-Error249";
  40.                 //lblError.Visible = true;
  41.                 lblMessage.Text = PSResource.PSResourceName;
  42.                 lblMessage.Visible = true;
  43.             }
  44.  
  45.         }
  46.  
This is in Code behind Page....
Expand|Select|Wrap|Line Numbers
  1.    <script type="text/javascript" language="javascript">
  2. function  printseleteditems()
  3. {
  4. window.print();
  5. }
  6.     </script>
  7.  
  8.  
This is in Design Page....
Jan 21 '09 #5

Frinavale
Expert Mod 5K+
P: 9,731
I'm not sure what you're doing in the above posted code.
I thought that you wanted to print selected files?
I'm assuming these files are text based...
If I were you I would loop through the names (and paths) of the selected files, read from the files and append their content to your string builder. Every time I would append a new file I would wrap it in a <div> with CSS class is set to something that would indicate a new page.

Pseudo code:

For each selectedFile
append "<div class="newDocument">" to the string builder
then append the file content
then append the closing "</div>"
Loop

After creating the content to be printed, add the JavaScript that prints to a button that allows them to print.

To make sure that each document was printed on a new page I would set the CSS class to:
.newDocument
{
page-break-after: always;
}

Check out the other Printing Styles available.

-Frinny
Jan 21 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.