package pdf import ( "fmt" "log/slog" "os" "os/exec" "path/filepath" "time" ) // Generate generates the CV PDF document from the JSON file. func Generate(tempDir, input string, historyLimit time.Time, verbose bool) (string, error) { texFileName, err := tex(input, tempDir, historyLimit) if err != nil { return "", fmt.Errorf("unable to create the tex file; %w", err) } slog.Info("Creating the PDF document.") pathArg := "--path=" + tempDir command := exec.Command("mtxrun", pathArg, "--script", "context", texFileName) if verbose { command.Stderr = os.Stderr command.Stdout = os.Stdout } if err := command.Run(); err != nil { return "", fmt.Errorf("an error occurred when creating the PDF file; %w", err) } output := filepath.Join(tempDir, "cv.pdf") slog.Info("PDF document successfully created.", "filename", output) return output, nil }