Menu

Save PDF file to current working directory without prompting user

ajmakoni
2017-09-15
2017-09-15
  • ajmakoni

    ajmakoni - 2017-09-15

    Hello,
    I would like to find out how I can modify the source to disable SAVE PDF
    user prompt and instead let the program save the PDF to the current working
    directory and automatically close the program.

     
  • ajmakoni

    ajmakoni - 2017-09-17

    After some hours of figiting with the code,I found the solution:
    Basically you set your properties in SavePDF function that is inside NASP2.WinForms.WinFormsExportHelper .
    In my case, the two lines did the trick:

    pdfSettings.DefaultFileName=Paths.MyFiles+"mypdf.pdf";
                    pdfSettings.SkipSavePrompt = true;
    

    You can edit them further to fit your choice. You can also pipe your results from this function to your desire output destination i.e streams
    Also Paths.MyFiles can be declare in Paths.cs or copy and paste Paths.Executable and change output folder name.
    To disable PDF overwriting prompt: got to NAPS2.core/ImportExport/Pdf/SavePdfOperation.cs under Start function and replace

    if (File.Exists(subFileName))
                {
                    if (overwritePrompt.ConfirmOverwrite(subFileName) != DialogResult.Yes)
                    {
                        return false;
                    }
                }
    

    with

    if (File.Exists(subFileName))
                {
                    /*if (overwritePrompt.ConfirmOverwrite(subFileName) != DialogResult.Yes)
                    {
                        return false;
                    }*/
                }
    

    Hope this helps someone

     

    Last edit: ajmakoni 2017-09-19

Log in to post a comment.

MongoDB Logo MongoDB