Sivish Web Solutions

Navigation Menu

Visual Studio 2012 Release Candidate – Set up Experience..

Posted by on May 31, 2012 in ASP.NET, Blog, c#, VS2012 | 0 comments

Visual Studio 2012 RC has been released today. and I am very happy to download and install Express edition for Web. ¬†I cannot resist myself ūüôā So quickly I would like to share my set up experiences. The installer has been modified to match Windows 8 standards.¬†While installing the ¬†product, it wanted me to restart my machine couple of times. First time, after installing the framework (.Net Framework 4.5) and second time after installing the complete product. So look at the screen shots below in the order.. ūüôā This slideshow requires JavaScript. You can found “what’s New” from the following link. http://msdn.microsoft.com/en-us/library/hh420390(v=VS.110).aspx I will be back with few tutorials about new...

Read More

Printing without Status Dialogues in C# (Silent printing)

Posted by on Apr 24, 2012 in Blog, c#, Printing, VS2010 | 3 comments

In developer’s life, it is so common we used to encounter lot of issues. I am working in a small proof concept. Automatically printing documents to file or printer in C# (.Net Framework 4.0). ¬† ¬† ¬† ¬†¬†private void Print() ¬† ¬† ¬† ¬† { ¬† ¬† ¬† ¬† ¬† ¬† if (m_streams == null || m_streams.Count == 0) ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† throw new Exception(“Error: no stream to print.”); ¬† ¬† ¬† ¬† ¬† ¬† PrintDocument printDoc = new PrintDocument(); ¬† ¬† ¬† ¬† ¬† ¬† if (!printDoc.PrinterSettings.IsValid) ¬† ¬† ¬† ¬† ¬† ¬† { ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† throw new Exception(“Error: cannot find the default printer.”); ¬† ¬† ¬† ¬† ¬† ¬† } ¬† ¬† ¬† ¬† ¬† ¬† else ¬† ¬† ¬† ¬† ¬† ¬† { ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† printDoc.PrintPage += new PrintPageEventHandler(PrintPage); ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† m_currentPageIndex = 0; ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† if (printDoc.PrinterSettings.PrinterName == “Microsoft XPS Document Writer”) ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† { ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† printDoc.PrinterSettings.PrintToFile = true; ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† if (filename == “”) ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† printDoc.PrinterSettings.PrintFileName = DateTime.Now.Ticks.ToString() + “.xps”; ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† else ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† printDoc.PrinterSettings.PrintFileName = filename; ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† } ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† printDoc.Print(); ¬† ¬† ¬† ¬† ¬† ¬† } ¬† ¬† ¬† ¬† } But while printing the documents to file, I was annoyed by a pop up which showed me Printing page 1 of 5. I wanted to get rid of that. ¬† After a bit google and MSDN, I have found that Print controller PrintController¬†class Controls how a document is printed, when printing from a Windows Forms application. If you look at the PrintDocument class Meta data view, you will notice the following statement. ¬† ¬† ¬†...

Read More