From 429a6aad0bd43f1228e875a3921cd8a01c6f5c61 Mon Sep 17 00:00:00 2001 From: le0m Date: Tue, 27 Aug 2024 10:03:04 +0200 Subject: [PATCH] feat: function to check if the browser is still running --- print2pdf/print.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/print2pdf/print.go b/print2pdf/print.go index 7b867b4..577b5a1 100644 --- a/print2pdf/print.go +++ b/print2pdf/print.go @@ -155,6 +155,11 @@ func getPrintParams(data GetPDFParams) (page.PrintToPDFParams, error) { return params, nil } +// Check if the browser is still running. +func Running() bool { + return browserCtx != nil && browserCtx.Err() == nil +} + // Get a buffer of bytes representing a webpage in PDF format. func GetPDFBuffer(ctx context.Context, data GetPDFParams, res *[]byte) error { defer Elapsed("Total time to print PDF")()