Skip to content

Commit

Permalink
Allow setting output filename in -print-settings from command line
Browse files Browse the repository at this point in the history
Closes #3917
  • Loading branch information
wqweto authored and kjk committed Nov 28, 2023
1 parent 45fc6d3 commit 4dd1e7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void Printer::SetDevMode(DEVMODEW* dm) {

Printer::~Printer() {
str::Free(name);
str::Free(output);
free((void*)devMode);
free((void*)papers);
free((void*)paperSizes);
Expand Down Expand Up @@ -296,6 +297,9 @@ static bool PrintToDevice(const PrintData& pd) {
} else {
di.lpszDocName = ToWStrTemp(engine.FilePath());
}
if (pd.printer->output) {
di.lpszOutput = ToWStrTemp(pd.printer->output);
}

int current = 1, total = 0;
if (pd.sel.size() == 0) {
Expand Down Expand Up @@ -1151,6 +1155,8 @@ static void ApplyPrintSettings(Printer* printer, const char* settings, int pageC
// alternatively allow indicating the paper kind directly by number
devMode->dmPaperSize = GetPaperKind(s + 10);
devMode->dmFields |= DM_PAPERSIZE;
} else if (str::StartsWithI(s, "output=")) {
printer->output = str::Dup(s + 7);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Print.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PaperFormat GetPaperFormatFromSizeApprox(SizeF size);

struct Printer {
char* name = nullptr;
char* output = nullptr;
DEVMODEW* devMode = nullptr;
PRINTER_INFO_2* info = nullptr;

Expand Down

0 comments on commit 4dd1e7c

Please sign in to comment.