Wednesday, November 1, 2017

Free HTML to PDF library  .NET (c#)


You may find various libraries that convert HTML to pdf. But for me, I find SelectPDF the best. This library can help those developers who want it for free to convert few (not more than 5) pages long.
You can easily convert any webpage to pdf with different page settings parameters and custom pdf page breaks.
SelectPDF provides you a full featured free(community edition) .NET library for HTML to PDF conversion. Its only limitation is that it can generate pdf up to 5 pages. 

With few lines of codes, you can convert your URL or HTML to pdf content.

            // instantiate the html to pdf converter
     HtmlToPdf converter = new HtmlToPdf();

     // convert the URL to pdf
     PdfDocument doc = converter.ConvertUrl(url);

     // save pdf document
     doc.Save(file);

     // close pdf document
     doc.Close();



You can also get the library in visual studio from nuget.

Monday, October 30, 2017

Run multiple projects in Visual Studio


During application development, we might need to run multiple projects within the solution in visual studio. We can set one project as default. We can also run other projects in parallel within visual studio using the following steps.

Let's suppose 'Project1' is your default startup project and you want to start another project 'Project2' in the same solution.
  1. Run you default project ( i.e Project1 ).
  2. Then 'right-click' your second project ( i.e Project2 ),  go to 'Debug' and click 'Start new instance'.
  3. You should have both of your projects running.


Timer to shutdown your computer


Have you ever been in a condition when you are in hurry or you have to go away from your computer but you need your computer to work for a certain time and then shutdown automatically? Had there been a case where you need to be in front of your computer for some download to complete and then shutdown?

We can set a shutdown timer after a defined time when we want to shut down our system.

You can follow the following steps.
  • Open 'Run' and Type 'shutdown -s -f -t time_in_seconds' like shown in the figure below and click 'OK' .


Your computer will shutdown at your given time.



  • To Undo or Abort it, open 'Run' and type 'shutdown -a' and click 'OK' .

This will abort your shutdown timer and you can again continue to work normally.