0

Currently I have this test code

    File file = new File();
    Document document = file.Document;
    Page page = new Page(document);

    document.Pages.Add(page);

    PrimitiveComposer composer = new PrimitiveComposer(page);
    composer.SetFont(new StandardType1Font(document, StandardType1Font.FamilyEnum.Courier, true, false), 32);
    composer.ShowText("Hello World!", new PointF(32, 48));

    composer.Flush();
    file.Save("test.pdf", SerializationModeEnum.Incremental);
    System.Diagnostics.Process.Start("explorer", System.IO.Directory.GetParent(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName).ToString());

How can I open a general windows explorer save as prompt instead of saving to the hard code path "test.pdf"? (In file.save())

Thanks

Jon0149
  • 13
  • 1
  • 1
  • 5

1 Answers1

0

Use SaveFileDialog for that:

https://msdn.microsoft.com/en-us/library/sfezx97z(v=vs.110).aspx

   SaveFileDialog saveFileDialog1 = new SaveFileDialog();  
   saveFileDialog1.Filter = "PDF File|*.pdf";  
   saveFileDialog1.Title = "Save PDF";  

   if(saveFileDialog1.ShowDialog() == DialogResult.OK)  
   {  
       file.Save(saveFileDialog1.FileName, SerializationModeEnum.Incremental);
   }  
NicoRiff
  • 4,803
  • 3
  • 25
  • 54
  • This is really good but it opens two save as dialog boxes, one with no filename, then when i put one in it opens another with the full path in the name field, then i hit save and it saves in the right place; one dialog box would be better – Jon0149 Feb 22 '17 at 14:15
  • @Jon0149 use the code I edited. The old one had two ShowDialog – NicoRiff Feb 22 '17 at 14:16