Created
December 1, 2020 16:14
-
-
Save mhart/e3a60195f9cc83e746fe81804ff7148e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
import ( | |
"os" | |
"os/exec" | |
"strings" | |
) | |
func main() { | |
os.Chdir("/tmp") // Change working directory to /tmp so we can write files | |
pdf2png() | |
} | |
func pdf2png() error { | |
cmds := ` | |
rm -rf output | |
mkdir output | |
pdftocairo -png input.pdf output/converted | |
` | |
cmd := exec.Command("sh", "-cex", strings.TrimSpace(cmds)) | |
cmd.Stdout = os.Stdout | |
cmd.Stderr = os.Stderr | |
return cmd.Run() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment