Skip to content
Loading
 
+1
  • +1
    Hi Sachin
     
    Thanks for this
     
    but it having many issues
    1.only download once
    2.Not Download complete View Page as same style 
    +1
  • Jignesh Kumar
    +1
    Hi Sourav,
     
    Please refer this article, Instead of save as method you need to render apply download one.
    https://www.c-sharpcorner.com/article/export-data-in-excel-pdf-csv-word-json-xml-and-text-file-in-mvc-application/
    https://ironpdf.com/tutorials/html-to-pdf/ 
    +1
  • +1
    Given a view page, you can use the Virtual Printer in the LEADTOOLS SDK to convert a page to a PDF in a .NET Core app. The Virtual Printer can be used to capture a print job, and then used to save the image to the file. This supports a large variety of other file format which you can try. Here is code that you can use to get started.
     
    1. LeadPrinter = new Printer(printerName);     
    2. LeadPrinter.EmfEvent += new EventHandler(LeadPrinter_EmfEvent);     
    3. LeadPrinter.JobEvent += new EventHandler(LeadPrinter_JobEvent);     
    4.      
    5. DocumentWriter = new DocumentWriter();     
    6.     
    7. static void LeadPrinter_EmfEvent(object sender, EmfEventArgs e)     
    8. {     
    9.     Metafile metaFile = new Metafile(e.Stream);     
    10.      
    11.     DocumentWriterEmfPage documentPage = new DocumentWriterEmfPage     
    12.     {     
    13.         EmfHandle = metaFile.GetHenhmetafile()     
    14.     };     
    15.     DocumentWriter.AddPage(documentPage);     
    16. }     
    17.      
    18. static void LeadPrinter_JobEvent(object sender, JobEventArgs e)     
    19. {     
    20.     string printerName = e.PrinterName;     
    21.     int jobID = e.JobID;     
    22.      
    23.     if (e.JobEventState == EventState.JobStart)     
    24.     {     
    25.         OutputFile = Path.Combine(@"C:\Temp", Path.ChangeExtension(Path.GetRandomFileName(), "pdf"));     
    26.         DocumentWriter.BeginDocument(OutputFile, DocumentFormat.Pdf);     
    27.      
    28.         Console.WriteLine($"Job {jobID} for {printerName} was started");     
    29.     }     
    30.     else if (e.JobEventState == EventState.JobEnd)     
    31.     {     
    32.         DocumentWriter.EndDocument();     
    33.      
    34.         Console.WriteLine($"Job {jobID} for {printerName} was ended. PDF saved to {OutputFile}");     
    35.     }     
    36. }    
     
    https://www.leadtools.com/help/sdk/v21/tutorials/virtual-printer/windows/dotnet/print-to-file-using-the-virtual-printer-driver.html
    https://www.leadtools.com/help/sdk/v21/dh/pr/introduction.html
    +1