Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

How To Active print setting in Local html File

crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

How To Active print setting in Local html File

Post by crystalxp »

Hello, I Try to load a html with flash plugin , and here is a button to Call System printer setting , In IE, It Calls well(Of course , It will ask for script run permission )。but in CEF, When Click the button ,Nothing appened, I have Tried GlobalCEFApp.AddCustomCommandLine('--enable-local-file-accesses');

anythings should I go before call this?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How To Active print setting in Local html File

Post by salvadordf »

Hi,

If you are loading a local html file with a file:/// URL, you will have some restrictions.
Chromium do that for safety reasons and that's why it's recommended to load local files in CEF with a custom resource handler.

Check the CustomResourceBrowser demo.
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

Re: How To Active print setting in Local html File

Post by crystalxp »

Thank you very much, I will try it, you are so nice man. :D :D :D :D
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

Re: How To Active print setting in Local html File

Post by crystalxp »

Hello,I have tried load it from Chromium_OnGetResourceHandler
if request.Url = 'http://printerpage/' then
begin
TempStream := TFileStream.Create(ExtractFilePath(Application.ExeName) +
'printerpagesetting.html',fmOpenRead);//which has a swf embedded in it
Result := TCustomResourceHandler.Create(browser, frame, '', request,
TStream(TempStream), CefGetMimeType('html'));
end
else if request.Url = 'http://printerpage/flashwithprintbutton.swf' then
Begin
TempStream := TFileStream.Create(ExtractFilePath(Application.ExeName) +
'flashwithprintbutton.swf',fmOpenRead);//press the button will show system printer setting well in ie(win10)
Result := TCustomResourceHandler.Create(browser, frame, '', request,
TStream(TempStream), CefGetMimeType('swf'));
end;

But the flash button still have (no right?) to show printer setting, what's wrong or any other solution
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

Re: How To Active print setting in Local html File

Post by crystalxp »

More:If it not because of right problem? then how to call printer in flash with cef
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How To Active print setting in Local html File

Post by salvadordf »

I know nothing about Adobe Flash programming but If you can't find a way to make it work you can also try the other workarounds for this kind of issues :
  • Use a custom scheme. You could use URLs that start with 'myprotocol://' instead of 'http://' and load your contents from disk. Take a look at the SchemeRegistrationBrowser demo for more info.
  • Another suggested workaround is using DATA urls.
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

Re: How To Active print setting in Local html File

Post by crystalxp »

Sorry for this, I have to add some information:
I test it in Chrome,IE,and Firefox, they can load and run print setting using file://......html , so i think it no need to understand how flash program it.....
but it can't work well in Cef4delphi demo browser...

Why?
I'm sorrry, but could you give us some demo on printer call (beside the window.print() using js :cry: :cry: :cry: :cry: )

thank you very much! :D :D :D :D :D :D
You do not have the required permissions to view the files attached to this post.
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

Re: How To Active print setting in Local html File

Post by crystalxp »

testfile is what i tested ...

thank you again.
You do not have the required permissions to view the files attached to this post.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How To Active print setting in Local html File

Post by salvadordf »

I'll take a look this weekend but I can't promise anything because I know nothing about Flash programming...
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

Re: How To Active print setting in Local html File

Post by crystalxp »

No matter what result, thanks for your job😁👍👍👍👍
Post Reply