locked
how to save pdf inside project folder RRS feed

  • Question

  • User-91993069 posted

    I am using this library for generating pdf

    pdf generate referance: https://help.syncfusion.com/file-formats/pdf/create-pdf-file-in-asp-net-mvc

    I am trying to save pdf in inside project/dataupload folder but pdf is save in dowload/document folder that is issue

            public ActionResult Create()
            {
                return View();
            }
            [HttpPost]
            public ActionResult Create(PdfDocument document)
            {
                        //---pdf create 
                        document = new PdfDocument();
                        PdfPage page = document.Pages.Add();
                        PdfGraphics graphics = page.Graphics;
                        PdfFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 20);
                        graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0));
                        string fullpath = Server.MapPath("~/DataUpload/") + filename;
                        document.Save(fullpath, HttpContext.ApplicationInstance.Response, HttpReadType.Save);  //here I am trying to generate pdf
                        //---pdf end

    Below folder I am trying to insert the pdf

    please help

    Friday, November 6, 2020 10:23 AM

Answers

  • User475983607 posted

    Set your browser's download folder to whatever you like or copy the file.  Keep in mind your requirement makes little sense.  I think you are confusing client and server.  Web user's that download the PDF will not have your project folders.

    Is your intent to save the file on the server?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 6, 2020 1:04 PM
  • User-474980206 posted

    The line

    document.Save(fullpath, HttpContext.ApplicationInstance.Response, HttpReadType.Save);  

    Writes the pdf to the response stream, that is it sends the file to the browser. The filename passed is used to give a default name (no folder path is supported). The browser user will need to select the folder.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 6, 2020 3:27 PM

All replies

  • User475983607 posted

    Set your browser's download folder to whatever you like or copy the file.  Keep in mind your requirement makes little sense.  I think you are confusing client and server.  Web user's that download the PDF will not have your project folders.

    Is your intent to save the file on the server?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 6, 2020 1:04 PM
  • User-474980206 posted

    The line

    document.Save(fullpath, HttpContext.ApplicationInstance.Response, HttpReadType.Save);  

    Writes the pdf to the response stream, that is it sends the file to the browser. The filename passed is used to give a default name (no folder path is supported). The browser user will need to select the folder.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 6, 2020 3:27 PM
  • User-91993069 posted

    hi bruce and mgebhard 

    Is your intent to save the file on the server?

    No, I want to save the file inside the project folder

    HttpContext.ApplicationInstance.Response, HttpReadType.Save //here I made the mistake so it store browser location folder
    Friday, November 6, 2020 4:29 PM