+
This is a test document to verify PDF generation works correctly.
+
It includes some basic styling and multiple elements.
+
+
+
+ `)
+
+ cfg := RenderConfig{
+ PageFormat: PageFormatA4,
+ Orientation: OrientationPortrait,
+ MarginTop: NewMarginInches(1.0),
+ MarginBottom: NewMarginInches(1.0),
+ MarginLeft: NewMarginInches(1.0),
+ MarginRight: NewMarginInches(1.0),
+ PrintBackground: true,
+ Scale: 1.0,
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+
+ reader, err := converter.GeneratePDF(ctx, htmlContent, cfg)
+ require.NoError(t, err)
+ require.NotNil(t, reader)
+
+ // Read the PDF content to verify it's not empty
+ pdfContent, err := io.ReadAll(reader)
+ require.NoError(t, err)
+ assert.Greater(t, len(pdfContent), 0)
+
+ // Verify it looks like a PDF file (starts with PDF magic bytes)
+ assert.True(t, bytes.HasPrefix(pdfContent, []byte("%PDF-")))
+}
+
+func TestGeneratePDF_ScaleHandling(t *testing.T) {
+ chromeAddr := os.Getenv("CHROME_WS_URL")
+ if chromeAddr == "" {
+ t.Skip("Skipping test: CHROME_WS_URL environment variable not set")
+ }
+
+ converter := NewConverter(chromeAddr)
+ htmlContent := []byte("