Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Open a PDF file in a new window
(10-11-2019, 05:03 PM)kudzu Wrote: Where is FileCopy? VCL has many methods for file copy, all of which are well documented:
Same applies for C++.

Otherwise check permissions and used account. If running as a service or IIS, network drives are not available as mapped letters unless that user has them mapped. Best to use UNC and make sure that user has permissions.

Hi Kudzu, FileCopy is in the IW.Common.SysTools unit.

(10-11-2019, 05:27 PM)Jose Nilton Pace Wrote: Hi Soren, try use IW Cache system:
procedure TIWForm5.IWGradButton1Click(Sender: TObject);
  xFileName: string;
  xURL: string;
  // get a new temp file name. This method only returns a file name, the file  is not created
  xFileName := TIWAppCache.NewTempFileName;
  // copy a sample pdf file to our new cache file. We are just simulating a pdf file creation
  FileCopy('your_file.pdf', xFileName, True);
  // add the pdf file to the cache. cache type is defined as ctOneTime, i.e., the file will be deleted when served
  xURL := TIWAppCache.AddFileToCache(Self, xFileName, TIWMimeTypes.GetAsString(mtPDF), ctOneTime);
  // open a new window with our PDF file
From here:

Hi Jose,

Thanks for the hint... I have finally managed to get it to work. It has taken me quite a long time but now it's working. Thanks to everyone for guides, hints and help. Without your help I would still have been the dark.

The key was in all of the 4 lines above in your hint, and especially in the FileCopy, where

'your_file.pdf', has been replaced by a filename like '\\\SalesReceipt\146\146968\14686943-631.pdf'.

One setback though is that it is not working on IE11. It's working fine on Edge, Chrome, Cliqz / Firefox, apart from having to allow popup on them all. I have not tested it on Safari.
On IE11 it opens up a new, but blank screen, and blocks the workstation for a number of seconds. Mostly it is possible to close the new window again, but often it is necessary to close the browser with all open tabs.

I hope I'll find a solution to that, and should anyone have any knowledge of solutions, please let me know. One possible reason, as far as I've read, can be that Acrobat Reader is not installed correctly in relation to IE11. Recommends are to de-install and re-install, but I have not tried that yet.

Anyway, time for a bit of rest now. At least until tomorrow.


Messages In This Thread
Open a PDF file in a new window - by SorenJensen - 10-10-2019, 09:18 PM
RE: Open a PDF file in a new window - by kudzu - 10-11-2019, 03:41 PM
RE: Open a PDF file in a new window - by kudzu - 10-11-2019, 05:03 PM
RE: Open a PDF file in a new window - by SorenJensen - 10-11-2019, 07:50 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)