Help to print the XML file

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2007
Posts: 59
Reputation: FaridMasood is an unknown quantity at this point 
Solved Threads: 0
FaridMasood's Avatar
FaridMasood FaridMasood is offline Offline
Junior Poster in Training

Help to print the XML file

 
0
  #1
Jul 21st, 2008
If someone has any idea that how to print the xml file.
Thanks and Best of Lusk,

Farid ud din Masood
MS.c (CS)
University of Agriculture, Faisalabad
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 111
Reputation: ChaseVoid is an unknown quantity at this point 
Solved Threads: 12
ChaseVoid's Avatar
ChaseVoid ChaseVoid is offline Offline
Junior Poster

Re: Help to print the XML file

 
0
  #2
Jul 21st, 2008
Didn't you post the same question in the C# forum?

Have you tried searching the web? Just go into the MSDN documentation, you'll find all your answers there.

To print XML form a dataset, you can use the WriteXml() function of the DataSet class.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 59
Reputation: FaridMasood is an unknown quantity at this point 
Solved Threads: 0
FaridMasood's Avatar
FaridMasood FaridMasood is offline Offline
Junior Poster in Training

Re: Help to print the XML file

 
0
  #3
Jul 22nd, 2008
Originally Posted by ChaseVoid View Post
Didn't you post the same question in the C# forum?

Have you tried searching the web? Just go into the MSDN documentation, you'll find all your answers there.

To print XML form a dataset, you can use the WriteXml() function of the DataSet class.
Thank you,
I fact i have posted this after searching over two days over internet but still unable to find a way to print the XML file to printer. Please help me.
Thanks and Best of Lusk,

Farid ud din Masood
MS.c (CS)
University of Agriculture, Faisalabad
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 111
Reputation: ChaseVoid is an unknown quantity at this point 
Solved Threads: 12
ChaseVoid's Avatar
ChaseVoid ChaseVoid is offline Offline
Junior Poster

Re: Help to print the XML file

 
0
  #4
Jul 22nd, 2008
>I fact i have posted this after searching over
>two days over internet
Well it seems like you haven't searched well. Anyways, you can find all the information about it in MSDN.
Just create a PrintDialog object and use it print the file.

  1. System.IO.StreamReader fileToPrint;
  2. System.Drawing.Font printFont;
  3.  
  4. //Write the following in the PrintButton
  5. //CLick Event
  6.  
  7. string printPath = this.textBox1.Text;
  8. fileToPrint = new System.IO.StreamReader(printPath);
  9. printFont = new System.Drawing.Font("Arial", 10);
  10. printDocument1.Print();
  11. fileToPrint.Close();
  12.  
  13. //In the PrintDialog's PrintPage Event
  14. //Handler do the following
  15. float yPos = 0f;
  16. int count = 0;
  17. float leftMargin = e.MarginBounds.Left;
  18. float topMargin = e.MarginBounds.Top;
  19. string line = null;
  20. float linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);
  21. while (count < linesPerPage)
  22. {
  23. line = fileToPrint.ReadLine();
  24. if (line == null)
  25. {
  26. break;
  27. }
  28. yPos = topMargin + count * printFont.GetHeight(e.Graphics);
  29. e.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos,
  30. new StringFormat());
  31. count++;
  32. }
  33. if (line != null)
  34. {
  35. e.HasMorePages = true;
  36. }
  37.  
  38. //Now in the browse button, form where
  39. //you get the xml filename into the
  40. //textbox, do the following in it's Click
  41. //Event.
  42.  
  43. OpenFileDialog openFileDialog1 = new OpenFileDialog();
  44. openFileDialog1.Filter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
  45. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  46. textBox1.Text = openFileDialog1.FileName;
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC