Skip to content

Paper size calculations are incorrect #143

Description

@ynakatake

Hello.

The part regarding the calculation of paper size (https://github.com/Igor-Vladyka/leaflet.browser.print/blob/d8052cb02e338fe907d8e67cd4d5002f2227162c/src/leaflet.browser.print.helpers.js#L49C1-L78C4) is correct from A0 to A4 in A-format, but incorrect from A5.

The proposed correction is below.

	if (switchSides) {
-		w = w / (mode.options.pageSeriesSize - 1 || 1);
+		w = w / Math.pow(2,Math.floor(mode.options.pageSeriesSize / 2));
-		h = h / (mode.options.pageSeriesSize + 1);
+		h = h / Math.pow(2,Math.floor(mode.options.pageSeriesSize / 2) + 1);
	} else {
-		w = w / mode.options.pageSeriesSize;
+		w = w / Math.pow(2,Math.floor(mode.options.pageSeriesSize / 2));
-		h = h / mode.options.pageSeriesSize;
+		h = h / Math.pow(2,Math.floor(mode.options.pageSeriesSize / 2));
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions