Jump to content

Print Screen (screenshot) and save as pdf or jpeg


SergioFeitoza

Recommended Posts

When I am running my code I need to  save as jpeg or pdf a screenshot of that page. 

I found the sample \FMSoft\Framework\uniGUI\Demos\Desktop\HTML2Image that seems to do more or less what I need 

As written in the demo it is necessary to install  an external tool downloadable in  from https://wkhtmltopdf.org/ and install it.
 My question is : is there  any resource available which does  not  request to install the external tool ?

Thanks in advance

Link to comment
Share on other sites

23 hours ago, SergioFeitoza said:

Thanks Sherzod   Looks great   Tomorrow I will try with it

Hi Sherzod
I followed your suggestion and worked in it. I could run the code below without errors but do not know where the screenshot was saved  (no visualization cames).. Unfortunately my code is very big to post here and be understood.


My intention is to SAVE a printscreen of the complete page (pdf or jpg or png ) and after to send it by e-mail.

I need to screenshot the whole page and not just a component of the page as in the code below (the tunipanel named pnlTSaccount ) 

I need to screenshot like is done here https://html2canvas.hertzen.com/ (Click button TRYOUT and after button CAPTURE)

I know how to send by email if I know  the directory where the screenshot was saved.

I have 3 doubts. 

1) If I replace the the panel pnlTSaccount of the code below by "MainForm" it does not compile. The many components of my main page are not in a single container.

So I need a printscreen of the whole page.. . What should I do ?

2) I do not understand yet in which directory the screenshot is saved.  I checked the directory ... FILES but was not there. I included Files in the ervermodule.customfiles 
How to write the code below to save  the screenshot in the ...Files directory?


3) What should I write in the text below to save the screenshot as jpeg ?

------------------------------------
procedure TMainForm.ReportViaEmailClick(Sender: TObject);
  var
  fName: string;
 begin
    fName := 'capture' + FormatDateTime('ddmmyyyyhhnnss', Now);

    pnlTSaccount.JSInterface.JSCode(
      'html2canvas(document.querySelector("#'+ pnltopmain.JSId +'")).then(function(canvas) {'+
      '    canvasSaveAs(canvas.toDataURL(), "'+ fName +'");'+
      '});'
    );

 /////    UniMainModule.SMTPSEND(LOGIN, USERNAME,'REPORT');                 ///// SMTPSEND    SMTPSEND
 /////   showMessage(' Check your e-mail inbox. This page is attached to an e-mail');
end

Link to comment
Share on other sites

19 hours ago, SergioFeitoza said:

Hi Sherzod
I followed your suggestion and worked in it. I could run the code below without errors but do not know where the screenshot was saved  (no visualization cames).. Unfortunately my code is very big to post here and be understood.


My intention is to SAVE a printscreen of the complete page (pdf or jpg or png ) and after to send it by e-mail.

I need to screenshot the whole page and not just a component of the page as in the code below (the tunipanel named pnlTSaccount ) 

I need to screenshot like is done here https://html2canvas.hertzen.com/ (Click button TRYOUT and after button CAPTURE)

I know how to send by email if I know  the directory where the screenshot was saved.

I have 3 doubts. 

1) If I replace the the panel pnlTSaccount of the code below by "MainForm" it does not compile. The many components of my main page are not in a single container.

So I need a printscreen of the whole page.. . What should I do ?

2) I do not understand yet in which directory the screenshot is saved.  I checked the directory ... FILES but was not there. I included Files in the ervermodule.customfiles 
How to write the code below to save  the screenshot in the ...Files directory?


3) What should I write in the text below to save the screenshot as jpeg ?

------------------------------------
procedure TMainForm.ReportViaEmailClick(Sender: TObject);
  var
  fName: string;
 begin
    fName := 'capture' + FormatDateTime('ddmmyyyyhhnnss', Now);

    pnlTSaccount.JSInterface.JSCode(
      'html2canvas(document.querySelector("#'+ pnltopmain.JSId +'")).then(function(canvas) {'+
      '    canvasSaveAs(canvas.toDataURL(), "'+ fName +'");'+
      '});'
    );

 /////    UniMainModule.SMTPSEND(LOGIN, USERNAME,'REPORT');                 ///// SMTPSEND    SMTPSEND
 /////   showMessage(' Check your e-mail inbox. This page is attached to an e-mail');
end

Any idea?

Link to comment
Share on other sites

4 minutes ago, Sherzod said:

Hi,

If I am not mistaken, you need to analyze this post:

 

Hi Sherzod This is one of the good posts I went through before writing. However even after running the code above I remained with these basic doubts:

1) If I replace the name of a component to snapshot by "MainForm" it does not compile. The many components of my main page are not in a single container.

So I need a printscreen of the whole page.. . What should I do ?

2) I do not understand yet in which directory the screenshot is saved.  I checked the directory ... FILES but was not there. I included Files in the ervermodule.customfiles 
How to write the code below to save  the screenshot in the ...Files directory?

3) What should I write  to save the screenshot as jpeg ?

  • Upvote 1
Link to comment
Share on other sites

If I am in my computer and want to save a printscreen on my C:/sergiodirectory I do:

a)       Click the keyboard key PrintScreen

b)      Open my old Paint

c)       Click Control+V putting the myimage in Paint

d)      SaveAs myImage in the directory C:/sergiodirectory

e)      What is the Unigui code (and where to insrt it step by step)  that I have to write in my Unigui code to do exactly this ?

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...