Downloadable PDF functionalities are part of different websites. PDF or excel downloads have a large number of ways to do. Excel is easy, but PDFs usually have issues with CSS and many more.
I have done a lot more research on this and found the usage of CutyCapt.exe more convenient to capture a webpage as a PDF or Image.
What is CutyCapt?
CutyCapt is a small cross-platform command-line utility to capture WebKit's rendering of a web page into a variety of vector and bitmap formats, including SVG, PDF, PS, PNG, JPEG, TIFF, GIF, and BMP. See IECapt for a similar tool based on Internet Explorer.
Requirements
- The process of PDF creation is done using an executable file called CutyCapt.exe. Download the exe and add it to the solution.
- If we are working with the ASP.NET project, the exe can be called on a redirection page. This page will be blank with the following code on page load.
Implementation
- Create a file name and path: To make the filename unique I would prefer a GUID. (It is the choice of the developer according to the requirement and logic). The file Url is then added to a string.
- string filename = Guid.NewGuid() + ".pdf"; //unique file name
- // url of the pdf file name
- string url = “http://example.org” +"/CutyCapt/" + filename;
- Location of the executable: The location of the CutyCapt.exe is assigned to a string.
- //location of Executable
- string cutycaptLocation = "D:\\CutyCapt";
- Command creation: For creating the command in ASP.NET, we use the ProcessStartInfo object.
Different parameters are assigned to the object as properties like the following:
a. CreateNoWindow
b. WorkingDirectory
c. FileName
d. Arguments
- link of the page which needs to be converted to PDF
- the destination folder
e. UseShellExecute- // Command for execution
- System.Diagnostics.ProcessStartInfo pi = new System.Diagnostics.ProcessStartInfo();
- pi.CreateNoWindow = false;
- pi.WorkingDirectory = cutycaptLocation;
- pi.FileName = cutycaptLocation + "\\CutyCapt.exe";
- pi.Arguments = "--url=" + link + " --out-format=pdf -out=" + System.IO.Path.GetFullPath(Server.MapPath("~/CutyCapt")) + "\\" + filename;
- pi.UseShellExecute = false;
- Process execution: Process object in ASP.Net is used to execute the process, for the info created.
- try {
- // Start the process with the info we specified.
- // Call WaitForExit and then the using statement will close.
- using(System.Diagnostics.Process exeProcess = System.Diagnostics.Process.Start(pi)) {
- exeProcess.WaitForExit();
- }
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- }
- Redirect to PDF: Once the PDF is created the browser is redirected to the PDF link loading the PDF created.
- Response.Redirect(url);
The PDF file for the specified page is ready to be saved to the system. This is the easiest way to create a PDF in my experience.
Please feel free to put in your comments on this.

Ankit BansalPosted Sep 10, 2015, 1:03 AM
good one..thanks...
Pankaj Kumar ChoudharyPosted Sep 9, 2015, 9:35 PM
Nice Explain Mam........
Santhakumar MunuswamyPosted Sep 9, 2015, 3:18 PM
Thanks for nice article
Mohammed IbrahimPosted Sep 9, 2015, 2:05 PM
nice share
Upendra Pratap ShahiPosted Sep 9, 2015, 12:13 PM
nice one
Karthikeyan KPosted Sep 9, 2015, 12:12 PM
Good one mam...Thanks for sharing us
RakeshPosted Sep 9, 2015, 12:08 PM
Good one