Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
feat: bump SumatraPDF from 3.3.3 to 3.4.6 (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
artiebits authored Nov 1, 2022
1 parent 9f88d99 commit b8c639c
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 105 deletions.
Binary file renamed src/SumatraPDF.exe → src/SumatraPDF-3.4.6-64.exe
Binary file not shown.
192 changes: 89 additions & 103 deletions src/print/print.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ it("sends the PDF file to the default printer", async () => {

await print(filename);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to-default", "-silent", filename]
);
});

it("sends PDF file to the specific printer", async () => {
Expand All @@ -61,12 +60,10 @@ it("sends PDF file to the specific printer", async () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to",
printer,
"-silent",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to", printer, "-silent", filename]
);
});

it("sends PDF file to the specific printer with a space in its name", async () => {
Expand All @@ -76,26 +73,21 @@ it("sends PDF file to the specific printer with a space in its name", async () =

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to",
printer,
"-silent",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to", printer, "-silent", filename]
);
});

it("allows users to specify which pages to print in the document", async () => {
const filename = "assets/sample.pdf";
const options = { pages: "1,3" };
await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
"-print-settings",
"1,3",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to-default", "-silent", "-print-settings", "1,3", filename]
);
});

describe("paper size", () => {
Expand All @@ -116,13 +108,16 @@ describe("paper size", () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
"-print-settings",
`paper=${paperSize}`,
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
[
"-print-to-default",
"-silent",
"-print-settings",
`paper=${paperSize}`,
filename,
]
);
});
});

Expand All @@ -146,13 +141,16 @@ describe("orientation", () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
"-print-settings",
orientation,
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
[
"-print-to-default",
"-silent",
"-print-settings",
orientation,
filename,
]
);
});
});

Expand All @@ -177,13 +175,16 @@ describe("monochrome", () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
"-print-settings",
"monochrome",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
[
"-print-to-default",
"-silent",
"-print-settings",
"monochrome",
filename,
]
);
});

it("allows to print in color", async () => {
Expand All @@ -194,13 +195,10 @@ describe("monochrome", () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
"-print-settings",
"color",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to-default", "-silent", "-print-settings", "color", filename]
);
});
});

Expand All @@ -214,13 +212,10 @@ describe("subset", () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
"-print-settings",
"odd",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to-default", "-silent", "-print-settings", "odd", filename]
);
});
});

Expand All @@ -244,13 +239,10 @@ describe("scale", () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
"-print-settings",
scale,
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to-default", "-silent", "-print-settings", scale, filename]
);
});
});

Expand All @@ -274,13 +266,10 @@ describe("side", () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
"-print-settings",
side,
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to-default", "-silent", "-print-settings", side, filename]
);
});
});

Expand All @@ -303,13 +292,10 @@ describe("bin", () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
"-print-settings",
"bin=1",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to-default", "-silent", "-print-settings", "bin=1", filename]
);
});
});

Expand All @@ -320,13 +306,10 @@ describe("copies", () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
"-silent",
"-print-settings",
"3x",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to-default", "-silent", "-print-settings", "3x", filename]
);
});
});

Expand All @@ -336,10 +319,10 @@ it("does not set a printer when printDialog is set to true", async () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-dialog",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-dialog", filename]
);
});

it("allows to turn on SumatraPDF error messages", async () => {
Expand All @@ -348,10 +331,10 @@ it("allows to turn on SumatraPDF error messages", async () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to-default",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
["-print-to-default", filename]
);
});

it("allows to set multiple print settings", async () => {
Expand All @@ -367,14 +350,17 @@ it("allows to set multiple print settings", async () => {

await print(filename, options);

expect(execAsync).toHaveBeenCalledWith("mocked_path_SumatraPDF.exe", [
"-print-to",
"Zebra",
"-silent",
"-print-settings",
"1-3,5,odd,fit,bin=2,paper=A2",
filename,
]);
expect(execAsync).toHaveBeenCalledWith(
"mocked_path_SumatraPDF-3.4.6-64.exe",
[
"-print-to",
"Zebra",
"-silent",
"-print-settings",
"1-3,5,odd,fit,bin=2,paper=A2",
filename,
]
);
});

it("works when custom SumatraPDF path specified", async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/print/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default async function print(
if (!fs.existsSync(pdf)) throw "No such file";

let sumatraPdf =
options.sumatraPdfPath || path.join(__dirname, "SumatraPDF.exe");
options.sumatraPdfPath || path.join(__dirname, "SumatraPDF-3.4.6-64.exe");
if (!options.sumatraPdfPath) sumatraPdf = fixPathForAsarUnpack(sumatraPdf);

const args: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion webpack.production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
},
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin([{ from: "./src/SumatraPDF.exe" }]),
new CopyPlugin([{ from: "./src/SumatraPDF-3.4.6-64.exe" }]),
],
target: "node",
node: {
Expand Down

0 comments on commit b8c639c

Please sign in to comment.