From 7dee1e82f622063190d142eba3012926a7abb57d Mon Sep 17 00:00:00 2001 From: Bernard Xie Date: Mon, 27 Feb 2023 16:19:52 -0800 Subject: [PATCH] Update main.go --- d2cli/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/d2cli/main.go b/d2cli/main.go index 827db38e1..d7492e503 100644 --- a/d2cli/main.go +++ b/d2cli/main.go @@ -454,6 +454,11 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, ske } if !diagram.IsFolderOnly { + rootFill := diagram.Root.Fill + // gofpdf will print the png img with a slight filter + // strip out the background fill within the png so that the background is uniform in the exported pdf + diagram.Root.Fill = "transparent" + svg, err = d2svg.Render(diagram, &d2svg.RenderOpts{ Pad: int(pad), Sketch: sketch, @@ -480,7 +485,7 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, ske return svg, err } - err = pdf.AddPDFPage(pngImg, currBoardPath) + err = pdf.AddPDFPage(pngImg, currBoardPath, rootFill) if err != nil { return svg, err }