High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
feat: complete PDF CLI options implementation
Mariofb9aa80ec488
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0235b3dc..f445ea9b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,6 +4,7 @@### Added- **PDF export parameters** — `/pdf` API now supports full PrintToPDFParams: `paperWidth`, `paperHeight`, `marginTop`, `marginBottom`, `marginLeft`, `marginRight`, `pageRanges`, `displayHeaderFooter`, `headerTemplate`, `footerTemplate`, `generateTaggedPDF`, `generateDocumentOutline`, `preferCSSPageSize` (#45, PR #48)+- **Complete PDF CLI options** — `pinchtab pdf` command now supports all PDF export parameters matching the API functionality. Includes paper dimensions, margins, page ranges, headers/footers, and accessibility options (#54)- **Installer branding** — install.sh now uses yellow accent color (#fbbf24) and crab icon 🦀 for consistency (PR #48)- **Ad blocking** — New `blockAds` option blocks 100+ tracking/analytics domains for cleaner snapshots. Available via env var `BRIDGE_BLOCK_ADS=true`, CLI flag `--block-ads`, and API parameter (#50)diff --git a/README.md b/README.mdindex e05b3d4c..dc88d8d0 100644--- a/README.md+++ b/README.md@@ -354,7 +354,7 @@ pinchtab press Enter # Press keypinchtab text # Extract readable textpinchtab ss -o page.jpg # Screenshotpinchtab eval "document.title" # Run JavaScript-pinchtab pdf -o page.pdf --landscape # Export PDF+pinchtab pdf -o page.pdf --landscape --page-ranges "1-3,5" # Export PDF with optionspinchtab tabs # List tabspinchtab tabs new https://httpbin.org # Open new tabpinchtab health # Check serverdiff --git a/cmd/pinchtab/cmd_cli.go b/cmd/pinchtab/cmd_cli.goindex 866585da..aa636c51 100644--- a/cmd/pinchtab/cmd_cli.go+++ b/cmd/pinchtab/cmd_cli.go@@ -37,7 +37,7 @@ CLI (requires running server):pinchtab tabs [new <url>|close <id>] Manage tabspinchtab ss [-o file] [-q 80] Screenshotpinchtab eval <expression> Run JavaScript- pinchtab pdf [-o file] [--landscape] Export page as PDF+ pinchtab pdf [-o file] [options] Export page as PDF (see PDF FLAGS)pinchtab health Check server statusSNAPSHOT FLAGS:@@ -49,6 +49,27 @@ SNAPSHOT FLAGS:--depth N Max tree depth--tab ID Target specific tab+PDF FLAGS:+ -o, --output FILE Output filename (default: page-{timestamp}.pdf)+ --landscape Landscape orientation+ --paper-width N Paper width in inches (default: 8.5)+ --paper-height N Paper height in inches (default: 11)+ --margin-top N Top margin in inches (default: 0.4)+ --margin-bottom N Bottom margin in inches (default: 0.4)+ --margin-left N Left margin in inches (default: 0.4)+ --margin-right N Right margin in inches (default: 0.4)+ --scale N Print scale 0.1-2.0 (default: 1.0)+ --page-ranges RANGE Pages to export (e.g., "1-3,5")+ --prefer-css-page-size Honor CSS @page size+ --display-header-footer Show header and footer+ --header-template HTML HTML template for header+ --footer-template HTML HTML template for footer+ --generate-tagged-pdf Generate accessible/tagged PDF+ --generate-document-outline Embed document outline+ --file-output Save to disk (server-side)+ --path PATH Custom file path (with --file-output)+ --tab ID Target specific tab+ENVIRONMENT:PINCHTAB_URL Server URL (default: http://127.0.0.1:9867)PINCHTAB_TOKEN Auth token (or BRIDGE_TOKEN for server)@@ -396,6 +417,75 @@ func cliPDF(client *http.Client, base, token string, args []string) {i++params.Set("tabId", args[i])}+ // Paper dimensions+ case "--paper-width":+ if i+1 < len(args) {+ i+++ params.Set("paperWidth", args[i])+ }+ case "--paper-height":+ if i+1 < len(args) {+ i+++ params.Set("paperHeight", args[i])+ }+ // Margins+ case "--margin-top":+ if i+1 < len(args) {+ i+++ params.Set("marginTop", args[i])+ }+ case "--margin-bottom":+ if i+1 < len(args) {+ i+++ params.Set("marginBottom", args[i])+ }+ case "--margin-left":+ if i+1 < len(args) {+ i+++ params.Set("marginLeft", args[i])+ }+ case "--margin-right":+ if i+1 < len(args) {+ i+++ params.Set("marginRight", args[i])+ }+ // Content options+ case "--page-ranges":+ if i+1 < len(args) {+ i+++ params.Set("pageRanges", args[i])+ }+ case "--prefer-css-page-size":+ params.Set("preferCSSPageSize", "true")+ // Header/Footer+ case "--display-header-footer":+ params.Set("displayHeaderFooter", "true")+ case "--header-template":+ if i+1 < len(args) {+ i+++ params.Set("headerTemplate", args[i])+ }+ case "--footer-template":+ if i+1 < len(args) {+ i+++ params.Set("footerTemplate", args[i])+ }+ // Accessibility+ case "--generate-tagged-pdf":+ params.Set("generateTaggedPDF", "true")+ case "--generate-document-outline":+ params.Set("generateDocumentOutline", "true")+ // Output options+ case "--file-output":+ params.Del("raw")+ params.Set("output", "file")+ case "--path":+ if i+1 < len(args) {+ i+++ params.Set("path", args[i])+ }+ case "--raw":+ params.Set("raw", "true")}}diff --git a/cmd/pinchtab/cmd_cli_test.go b/cmd/pinchtab/cmd_cli_test.goindex 7f1efa20..27d1cf4a 100644--- a/cmd/pinchtab/cmd_cli_test.go+++ b/cmd/pinchtab/cmd_cli_test.go@@ -451,6 +451,69 @@ func TestCLIPDF(t *testing.T) {}}+func TestCLIPDFAllOptions(t *testing.T) {+ m := newMockServer()+ m.response = "FAKEPDFDATA"+ defer m.close()+ client := m.server.Client()++ outFile := t.TempDir() + "/test.pdf"+ args := []string{+ "-o", outFile,+ "--landscape",+ "--scale", "1.5",+ "--paper-width", "11",+ "--paper-height", "8.5",+ "--margin-top", "1",+ "--margin-bottom", "1",+ "--margin-left", "0.5",+ "--margin-right", "0.5",+ "--page-ranges", "1-3,5",+ "--prefer-css-page-size",+ "--display-header-footer",+ "--header-template", "<span class='title'></span>",+ "--footer-template", "<span class='pageNumber'></span>",+ "--generate-tagged-pdf",+ "--generate-document-outline",+ "--tab", "tab-123",+ }++ cliPDF(client, m.base(), "", args)++ // Check all parameters were set correctly+ expectedParams := []string{+ "landscape=true",+ "scale=1.5",+ "paperWidth=11",+ "paperHeight=8.5",+ "marginTop=1",+ "marginBottom=1",+ "marginLeft=0.5",+ "marginRight=0.5",+ "pageRanges=1-3%2C5", // URL encoded+ "preferCSSPageSize=true",+ "displayHeaderFooter=true",+ "generateTaggedPDF=true",+ "generateDocumentOutline=true",+ "tabId=tab-123",+ "raw=true",+ }++ for _, expected := range expectedParams {+ if !strings.Contains(m.lastQuery, expected) {+ t.Errorf("expected %s in query, got %s", expected, m.lastQuery)+ }+ }++ // Check encoded HTML templates are present+ if !strings.Contains(m.lastQuery, "headerTemplate=") || !strings.Contains(m.lastQuery, "span") {+ t.Error("expected headerTemplate with HTML content")+ }+ if !strings.Contains(m.lastQuery, "footerTemplate=") || !strings.Contains(m.lastQuery, "pageNumber") {+ t.Error("expected footerTemplate with HTML content")+ }+}+// --- health tests ---func TestCLIHealth(t *testing.T) {