6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/bidi2pdf_rails/services/pdf_browser_session.rb', line 6
def run_browser_session
future = Concurrent::Promises.future do
Rails.application.executor.wrap do
browser = ChromedriverManagerSingleton.session.browser
context = browser.create_user_context
window = context.create_browser_window
tab = window.create_browser_tab
begin
prepare_tab(tab)
base64_data = tab.print(print_options: @print_options)
binary_pdf_content = Base64.decode64(base64_data)
notify_after_print(tab, binary_pdf_content)
ensure
tab&.close
window&.close
context&.close
ChromedriverManagerSingleton.session_close
end
end
end
future.value!
end
|