-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'AnkurGel-image_tiles' - image tile feature by @AnkurGel
- Loading branch information
Showing
6 changed files
with
100 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
env GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o builds/markpdf_darwin-amd64 | ||
env GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o builds/markpdf_darwin-amd64 | ||
upx builds/markpdf_darwin-amd64 | ||
|
||
env GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o builds/markpdf_darwin-arm64 | ||
# upx is not working properly for Mac M1 Build :( | ||
|
||
env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o builds/markpdf_linux-amd64 | ||
upx builds/markpdf_linux-amd64 | ||
|
||
env GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o builds/markpdf_linux-arm64 | ||
upx builds/markpdf_linux-arm64 | ||
|
||
env GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o builds/markpdf_windows-386.exe | ||
upx builds/markpdf_* | ||
upx builds/markpdf_windows-386.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/unidoc/unidoc/pdf/creator" | ||
"math" | ||
) | ||
|
||
// Watermarkable is a common interface for watermarkable image or paragraph | ||
type Watermarkable interface { | ||
creator.VectorDrawable | ||
SetPos(x, y float64) | ||
} | ||
|
||
func repeatTiles(watermark Watermarkable, c *creator.Creator) { | ||
w := watermark.Width() | ||
h := watermark.Height() | ||
pw := c.Context().PageWidth | ||
ph := c.Context().PageHeight | ||
|
||
nw := math.Ceil(pw / w) | ||
nh := math.Ceil(ph / h) | ||
|
||
debugInfo(fmt.Sprintf("Settings tiles of %v x %v", nw, nh)) | ||
for i := 0; i < int(nw); i++ { | ||
x := w * float64(i) | ||
for j := 0; j < int(nh); j++ { | ||
y := h * float64(j) | ||
watermark.SetPos(x + spacing * float64(i), y + spacing * float64(j)) | ||
err := c.Draw(watermark) | ||
if err != nil { | ||
fatalIfError(err, fmt.Sprintf("Error %s", err)) | ||
} | ||
} | ||
} | ||
} |