Save experiment in postgred integration

This commit is contained in:
Eli Ribble 2026-04-03 15:24:36 +00:00
parent 4f6369fa27
commit 2342a99405
No known key found for this signature in database
2 changed files with 46 additions and 0 deletions

1
.gitignore vendored
View file

@ -7,6 +7,7 @@ flogo.log
nidus-sync nidus-sync
nidus-sync.log nidus-sync.log
node_modules/ node_modules/
postgrid/cmd/send-pdf/send-pdf
result result
stadia/cmd/bulk-geocode/bulk-geocode stadia/cmd/bulk-geocode/bulk-geocode
stadia/cmd/reverse-geocode/reverse-geocode stadia/cmd/reverse-geocode/reverse-geocode

View file

@ -0,0 +1,45 @@
// Command pdf is a chromedp example demonstrating how to capture a pdf of a
// page.
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/chromedp/cdproto/page"
"github.com/chromedp/chromedp"
)
func main() {
// create context
ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
// capture pdf
var buf []byte
if err := chromedp.Run(ctx, printToPDF(`https://www.google.com/`, &buf)); err != nil {
log.Fatal(err)
}
if err := os.WriteFile("sample.pdf", buf, 0o644); err != nil {
log.Fatal(err)
}
fmt.Println("wrote sample.pdf")
}
// print a specific pdf page.
func printToPDF(urlstr string, res *[]byte) chromedp.Tasks {
return chromedp.Tasks{
chromedp.Navigate(urlstr),
chromedp.ActionFunc(func(ctx context.Context) error {
buf, _, err := page.PrintToPDF().WithPrintBackground(false).Do(ctx)
if err != nil {
return err
}
*res = buf
return nil
}),
}
}