Saving PDF document from Electron app

Currently I'm creating a pdf document this way:

  try
    PDFLib:= TTMSFNCPDFLib.Create();
    PDFLib.BeginDocument('MyPDF.pdf');

    PDFLib.Header:= 'My header';
    PDFLib.Footer:= '';

    PDFLib.NewPage();

    PDFLib.Graphics.Font.Name := 'Arial';
    PDFLib.Graphics.Font.Size := 10;
    PDFLib.Graphics.Fill.Color := gcNull;

    point.X:= 20;
    point.Y:= 60;
    rect:= PDFLib.Graphics.DrawText('Project :', point);
    point.X:= rect.Right + 5;
    rect:= PDFLib.Graphics.DrawText('My project');

    PDFLib.EndDocument(true);
  finally
    PDFLib.Free();
  end;

After creation the pdf document is opened with name 'tmp.pdf' inside the browser, but is not stored locally inside the application directory. Are there any restriction for saving the pdf files locally?

Furthermore, the method TTMSFNCPDFLib.EndDocument() returns a MemoryStream. When I try:

PDFLib.EndDocument(true).SaveToFile('MyPDF.pdf');

There is an error message:
WebCorePDF_4

With an other demo project, which was working with TTMSFNCGraphicsPDFIO the local storage of the pdf file by TMemoryStream was no problem.

You can only use EndDocument(true).SaveToFile when you use BeginDocument without parameters

Thank you, the pdf file is now stored locally in my application path. There is no automatic opening of the file anymore, is that the correct behaviour?

Well, I can open it with the helper function

TTMSFNCUtils.OpenFile(FileName);

That is correct. When using a memory stream we want the user to be able to determine what to do with the PDF.