diff --git a/internal/pdf/generator.go b/internal/pdf/generator.go index 53e505b..09e7200 100644 --- a/internal/pdf/generator.go +++ b/internal/pdf/generator.go @@ -32,10 +32,25 @@ func (g *Generator) GenerateFromURL(ctx context.Context, url string) ([]byte, er ctx, cancel := context.WithTimeout(ctx, g.timeout) defer cancel() - // Create chromedp context - allocCtx, allocCancel := chromedp.NewContext(ctx) + // Create chromedp options for headless mode (especially for CI environments) + opts := append(chromedp.DefaultExecAllocatorOptions[:], + chromedp.Flag("headless", true), + chromedp.Flag("disable-gpu", true), + chromedp.Flag("no-sandbox", true), + chromedp.Flag("disable-dev-shm-usage", true), + ) + + // Create exec allocator with custom options + allocCtx, allocCancel := chromedp.NewExecAllocator(ctx, opts...) defer allocCancel() + // Create chromedp context + browserCtx, browserCancel := chromedp.NewContext(allocCtx) + defer browserCancel() + + // Use browserCtx instead of allocCtx for chromedp operations + allocCtx = browserCtx + // Buffer to store PDF var pdfBuffer []byte