Jump to content

Image in TUniURLFrame


skafy

Recommended Posts

hi,

 

how can i load picture into TUniURLFrame? I tried next 

 

those two dont work

URLViewer.HTML.Add('<img src="/cache/Workflow_exe/'+ CacheFolder + '/' + Node.Text +'?fake='+ DateTimeToStr(Now) + '" style="width:100%;height:100%">')  //DONT WORK
URLViewer.HTML.Add('<iframe style="width:100%;height:100%;border:none;background-repeat:no-repeat;background-sizecontain;background-image:url(/cache/Workflow_exe/'+ CacheFolder + '/' + Node.Text +'?fake='+ DateTimeToStr(Now) +'");"></iframe>')  //DONT WORK

This one is working but sizes of picture are two big. scrollers appear.

URLViewer.URL:= '/cache/Workflow_exe/' + CacheFolder + '/' + Node.Text +'?fake=' + DateTimeToStr(Now);
  • Upvote 1
Link to comment
Share on other sites

I cant figure it out how to add attachment. There is no where add attachment button. I've searched it all o.O.

 

Basiclly what I want is to be able to insert image in TUniUrlFrame so that it fits. (I've tried width:100%;height:100% (no result)). But if I insert image with this

URLViewer.URL:= '/cache/Workflow_exe/' + CacheFolder + '/' + Node.Text +'?fake=' + DateTimeToStr(Now);

it shows image, but it also show picture in its natural scale, scrollers appear. I want insert image in TUniURLFrame so it fits (without scrollers)

Link to comment
Share on other sites

Hi,

 

Can you try this approach for now ?!:

procedure TMainForm.URLFrameFrameLoaded(Sender: TObject);
begin
  URLFrame.JSInterface.JSCode('try {var _img='#1'.iframe.contentWindow.document.images[0]; if (_img){_img.style["max-width"]="100%"; _img.style["max-height"]="100%";}} catch(e) {};');
end;
Link to comment
Share on other sites

I've updated and try it. It does not work. my code now is:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  URLFrame.JSInterface.JSCode('try {var _img='#1'.iframe.contentWindow.document.images[0]; if (_img){_img.style["max-width"]="100%"; _img.style["max-height"]="100%";}} catch(e) {};');
end;

procedure TMainForm.btnImageClick(Sender: TObject);
begin
  ShowAttachment('Example.png');
end;

procedure TMainForm.btnPDFClick(Sender: TObject);
begin
  ShowAttachment('3.pdf');
end;

procedure TMainForm.ShowAttachment(AFileName: string);
begin
  URLFrame.HTML.Add('<iframe style="border:none;background-repeat:no-repeat;background-sizecontain;background-image:url(/files/' + AFileName +'?fake='+ DateTimeToStr(Now) +'");"></iframe>')
end;
Link to comment
Share on other sites

Hi,

 

 

I've updated and try it. It does not work. my code now is:

procedure TMainForm.ShowAttachment(AFileName: string);
begin
  URLFrame.HTML.Add('<iframe style="border:none;background-repeat:no-repeat;background-sizecontain;background-image:url(/files/' + AFileName +'?fake='+ DateTimeToStr(Now) +'");"></iframe>')
end;

 

It seems that your HTML is not correct

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...