Recent

Author Topic: Open / Show PDF  (Read 1262 times)

Odanka

  • New Member
  • *
  • Posts: 40
Open / Show PDF
« on: September 03, 2019, 05:59:22 am »
I have successfully created a PDF file, but how do I view it?
Anyone Please..
Thank you..

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Open / Show PDF
« Reply #1 on: September 03, 2019, 08:26:44 am »
On Windows:

Code: Pascal  [Select][+][-]
  1. var
  2.   P: TProcess;
  3. begin
  4.   P := TProcess.Create(nil);
  5.   try
  6.     P.Executable := 'cmd';
  7.     P.Parameters.Add('/C');
  8.     P.Parameters.Add('filename_of_your.pdf');
  9.     P.Options := [poNoConsole];
  10.     P.Execute;
  11.   finally
  12.     P.Free;
  13.   end;
  14. end;
  15.  

For this to work you need to have installed a default PDF viewer.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Odanka

  • New Member
  • *
  • Posts: 40
Re: Open / Show PDF
« Reply #2 on: September 03, 2019, 08:55:58 am »
On Windows:

Code: Pascal  [Select][+][-]
  1. var
  2.   P: TProcess;
  3. begin
  4.   P := TProcess.Create(nil);
  5.   try
  6.     P.Executable := 'cmd';
  7.     P.Parameters.Add('/C');
  8.     P.Parameters.Add('filename_of_your.pdf');
  9.     P.Options := [poNoConsole];
  10.     P.Execute;
  11.   finally
  12.     P.Free;
  13.   end;
  14. end;
  15.  

For this to work you need to have installed a default PDF viewer.

For Android Please..

Odanka

  • New Member
  • *
  • Posts: 40
Re: Open / Show PDF
« Reply #3 on: September 03, 2019, 09:20:17 am »
Code: Pascal  [Select][+][-]
  1.       // Show PDF
  2.       jIntentManager_PDF.SetMimeType('application/pdf');
  3.       jIntentManager_PDF.SetDataUriAsString('file://'+
  4.         GetEnvironmentDirectoryPath(dirDCIM)+'/Mayari/Estimasi.pdf');
  5.  
  6.       if jIntentManager_PDF.ResolveActivity() then
  7.         jIntentManager_PDF.StartActivity()
  8.       else
  9.         ShowMessage('Whoops.., something went wrong..!');
  10.  
Solved by IntentDemo.
Thank you..

jt2003

  • Newbie
  • Posts: 3
Re: Open / Show PDF
« Reply #4 on: September 16, 2019, 08:38:10 pm »
This code works for me ( Intent )
=====================
CopyFromAssetsToEnvironmentDir('somefile.pdf',self.GetEnvironmentDirectoryPath(dirDownloads));
jIntentManager1.SetAction(iaView);
jIntentManager1.SetFlag(TIntentFlag.ifActivityNewTask);
jIntentManager1.SetDataAndType('content://'+self.GetEnvironmentDirectoryPath(dirDownloads)+'/somefile.pdf','application/pdf');
jIntentManager1.StartActivity();   

 

TinyPortal © 2005-2018