@open-pioneer/printing 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/Printing.js +61 -53
- package/Printing.js.map +1 -1
- package/PrintingController.d.ts +5 -5
- package/PrintingController.js +10 -18
- package/PrintingController.js.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @open-pioneer/printing
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3e7d978: Wrap the content of the printing widget into a `<form>`.
|
|
8
|
+
This change also fixes invalid DOM ids that were accidentally reused for the two form items.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- b152428: Update trails dependencies
|
|
13
|
+
- Updated dependencies [b152428]
|
|
14
|
+
- Updated dependencies [291ccb6]
|
|
15
|
+
- @open-pioneer/map@0.6.1
|
|
16
|
+
|
|
3
17
|
## 0.1.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/Printing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { Box, FormControl, HStack, FormLabel, Input, Select, Button } from '@open-pioneer/chakra-integration';
|
|
3
3
|
import { createLogger } from '@open-pioneer/core';
|
|
4
4
|
import { useMapModel } from '@open-pioneer/map';
|
|
@@ -15,16 +15,9 @@ const Printing = (props) => {
|
|
|
15
15
|
const [selectedFileFormat, setSelectedFileFormat] = useState("pdf");
|
|
16
16
|
const [title, setTitle] = useState("");
|
|
17
17
|
const [running, setRunning] = useState(false);
|
|
18
|
-
const printingService = useService("printing.PrintingService");
|
|
19
18
|
const notifier = useService("notifier.NotificationService");
|
|
20
19
|
const { map } = useMapModel(mapId);
|
|
21
|
-
const controller = useController(map, intl,
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
controller?.setFileFormat(selectedFileFormat);
|
|
24
|
-
}, [controller, selectedFileFormat]);
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
controller?.setTitle(title);
|
|
27
|
-
}, [controller, title]);
|
|
20
|
+
const controller = useController(map, intl, viewPadding);
|
|
28
21
|
function changeFileFormat(fileFormat) {
|
|
29
22
|
if (fileFormat === "png" || fileFormat === "pdf") {
|
|
30
23
|
setSelectedFileFormat(fileFormat);
|
|
@@ -35,7 +28,10 @@ const Printing = (props) => {
|
|
|
35
28
|
return;
|
|
36
29
|
}
|
|
37
30
|
setRunning(true);
|
|
38
|
-
controller.handleMapExport(
|
|
31
|
+
controller.handleMapExport({
|
|
32
|
+
title,
|
|
33
|
+
fileFormat: selectedFileFormat
|
|
34
|
+
}).catch((error) => {
|
|
39
35
|
const errorMessage = intl.formatMessage({ id: "printingFailed" });
|
|
40
36
|
notifier.notify({
|
|
41
37
|
level: "error",
|
|
@@ -46,54 +42,66 @@ const Printing = (props) => {
|
|
|
46
42
|
setRunning(false);
|
|
47
43
|
});
|
|
48
44
|
}
|
|
49
|
-
return /* @__PURE__ */
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
return /* @__PURE__ */ jsx(Box, { ...containerProps, children: /* @__PURE__ */ jsxs(
|
|
46
|
+
Box,
|
|
47
|
+
{
|
|
48
|
+
as: "form",
|
|
49
|
+
m: 2,
|
|
50
|
+
alignItems: "center",
|
|
51
|
+
onSubmit: (e) => {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
exportMap();
|
|
54
|
+
},
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ jsxs(FormControl, { as: HStack, mb: 2, children: [
|
|
57
|
+
/* @__PURE__ */ jsx(FormLabel, { minWidth: "82", mb: 1, children: intl.formatMessage({ id: "title" }) }),
|
|
58
|
+
/* @__PURE__ */ jsx(
|
|
59
|
+
Input,
|
|
60
|
+
{
|
|
61
|
+
placeholder: intl.formatMessage({ id: "input.placeholder" }),
|
|
62
|
+
value: title,
|
|
63
|
+
onChange: (event) => {
|
|
64
|
+
setTitle(event.target.value);
|
|
65
|
+
},
|
|
66
|
+
autoFocus: true
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
] }),
|
|
70
|
+
/* @__PURE__ */ jsxs(FormControl, { as: HStack, mb: 2, children: [
|
|
71
|
+
/* @__PURE__ */ jsx(FormLabel, { minWidth: "82", mb: 1, children: intl.formatMessage({ id: "fileFormat" }) }),
|
|
72
|
+
/* @__PURE__ */ jsxs(
|
|
73
|
+
Select,
|
|
74
|
+
{
|
|
75
|
+
value: selectedFileFormat,
|
|
76
|
+
onChange: (e) => changeFileFormat(e.target.value),
|
|
77
|
+
className: "printing-select",
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx("option", { value: "png", children: "PNG" }),
|
|
80
|
+
/* @__PURE__ */ jsx("option", { value: "pdf", children: "PDF" })
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] }),
|
|
53
85
|
/* @__PURE__ */ jsx(
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
placeholder: intl.formatMessage({ id: "input.placeholder" }),
|
|
57
|
-
value: title,
|
|
58
|
-
onChange: (event) => {
|
|
59
|
-
setTitle(event.target.value);
|
|
60
|
-
},
|
|
61
|
-
autoFocus: true
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
] }),
|
|
65
|
-
/* @__PURE__ */ jsxs(HStack, { mb: 2, children: [
|
|
66
|
-
/* @__PURE__ */ jsx(FormLabel, { minWidth: "82", mb: 1, children: intl.formatMessage({ id: "fileFormat" }) }),
|
|
67
|
-
/* @__PURE__ */ jsxs(
|
|
68
|
-
Select,
|
|
86
|
+
Button,
|
|
69
87
|
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
isLoading: running,
|
|
89
|
+
loadingText: intl.formatMessage({ id: "printingMap" }),
|
|
90
|
+
disabled: running,
|
|
91
|
+
mt: 2,
|
|
92
|
+
p: 2,
|
|
93
|
+
className: "printing-export-button",
|
|
94
|
+
type: "submit",
|
|
95
|
+
width: "100%",
|
|
96
|
+
children: intl.formatMessage({ id: "export" })
|
|
77
97
|
}
|
|
78
98
|
)
|
|
79
|
-
]
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
Button,
|
|
83
|
-
{
|
|
84
|
-
isLoading: running,
|
|
85
|
-
loadingText: intl.formatMessage({ id: "printingMap" }),
|
|
86
|
-
disabled: running,
|
|
87
|
-
padding: 2,
|
|
88
|
-
className: "printing-export-button",
|
|
89
|
-
onClick: exportMap,
|
|
90
|
-
width: "100%",
|
|
91
|
-
children: intl.formatMessage({ id: "export" })
|
|
92
|
-
}
|
|
93
|
-
)
|
|
94
|
-
] });
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
) });
|
|
95
102
|
};
|
|
96
|
-
function useController(map, intl,
|
|
103
|
+
function useController(map, intl, viewPadding) {
|
|
104
|
+
const printingService = useService("printing.PrintingService");
|
|
97
105
|
const [controller, setController] = useState(void 0);
|
|
98
106
|
useEffect(() => {
|
|
99
107
|
if (!map) {
|
package/Printing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Printing.js","sources":["Printing.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n Box,\n Button,\n FormControl,\n FormLabel,\n HStack,\n Input,\n Select\n} from \"@open-pioneer/chakra-integration\";\nimport { createLogger } from \"@open-pioneer/core\";\nimport { MapModel, useMapModel } from \"@open-pioneer/map\";\nimport { NotificationService } from \"@open-pioneer/notifier\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { FC, useEffect, useState } from \"react\";\nimport { FileFormatType, PrintingController } from \"./PrintingController\";\nimport type { ViewPaddingBehavior, PrintingService } from \"./index\";\n\nconst LOG = createLogger(\"printing\");\n\n/**\n * This is special property for the Printing.\n */\nexport interface PrintingProps extends CommonComponentProps {\n /**\n * The id of the map.\n */\n mapId: string;\n\n /**\n * Whether to respect the map view's padding when printing (default: `\"auto\"`).\n *\n * See also {@link ViewPaddingBehavior}.\n */\n viewPadding?: ViewPaddingBehavior;\n}\n\n/**\n * The `Printing` component can be used to download the current map view as a printable file.\n */\nexport const Printing: FC<PrintingProps> = (props) => {\n const intl = useIntl();\n\n const { mapId, viewPadding = \"auto\" } = props;\n const { containerProps } = useCommonComponentProps(\"printing\", props);\n const [selectedFileFormat, setSelectedFileFormat] = useState<FileFormatType>(\"pdf\");\n const [title, setTitle] = useState<string>(\"\");\n const [running, setRunning] = useState<boolean>(false);\n\n const printingService = useService<PrintingService>(\"printing.PrintingService\");\n const notifier = useService<NotificationService>(\"notifier.NotificationService\");\n\n const { map } = useMapModel(mapId);\n const controller = useController(map, intl, printingService, viewPadding);\n\n useEffect(() => {\n controller?.setFileFormat(selectedFileFormat);\n }, [controller, selectedFileFormat]);\n\n useEffect(() => {\n controller?.setTitle(title);\n }, [controller, title]);\n\n function changeFileFormat(fileFormat: string) {\n if (fileFormat === \"png\" || fileFormat === \"pdf\") {\n setSelectedFileFormat(fileFormat);\n }\n }\n\n function exportMap() {\n if (running || !controller) {\n return;\n }\n\n setRunning(true);\n controller\n .handleMapExport()\n .catch((error) => {\n const errorMessage = intl.formatMessage({ id: \"printingFailed\" });\n notifier.notify({\n level: \"error\",\n message: errorMessage\n });\n LOG.error(\"Failed to print the map\", error);\n })\n .finally(() => {\n setRunning(false);\n });\n }\n\n return (\n <Box {...containerProps}>\n <FormControl mb={4} alignItems=\"center\">\n <HStack mb={2}>\n <FormLabel minWidth=\"82\" mb={1}>\n {intl.formatMessage({ id: \"title\" })}\n </FormLabel>\n <Input\n placeholder={intl.formatMessage({ id: \"input.placeholder\" })}\n value={title}\n onChange={(event) => {\n setTitle(event.target.value);\n }}\n autoFocus // eslint-disable-line jsx-a11y/no-autofocus\n />\n </HStack>\n <HStack mb={2}>\n <FormLabel minWidth=\"82\" mb={1}>\n {intl.formatMessage({ id: \"fileFormat\" })}\n </FormLabel>\n <Select\n value={selectedFileFormat}\n onChange={(e) => changeFileFormat(e.target.value)}\n className=\"printing-select\"\n >\n <option value={\"png\"}>PNG</option>\n <option value={\"pdf\"}>PDF</option>\n </Select>\n </HStack>\n </FormControl>\n <Button\n isLoading={running}\n loadingText={intl.formatMessage({ id: \"printingMap\" })}\n disabled={running}\n padding={2}\n className=\"printing-export-button\"\n onClick={exportMap}\n width=\"100%\"\n >\n {intl.formatMessage({ id: \"export\" })}\n </Button>\n </Box>\n );\n};\n\n/**\n * Create a PrintingController instance to export the map view.\n */\nfunction useController(\n map: MapModel | undefined,\n intl: PackageIntl,\n printingService: PrintingService,\n viewPadding: ViewPaddingBehavior\n) {\n const [controller, setController] = useState<PrintingController | undefined>(undefined);\n\n useEffect(() => {\n if (!map) {\n return;\n }\n\n const controller = new PrintingController(map.olMap, printingService, {\n overlayText: intl.formatMessage({ id: \"printingMap\" })\n });\n setController(controller);\n\n return () => {\n controller.destroy();\n setController(undefined);\n };\n }, [map, intl, printingService]);\n\n useEffect(() => {\n controller?.setViewPadding(viewPadding);\n }, [controller, viewPadding]);\n\n return controller;\n}\n"],"names":["controller"],"mappings":";;;;;;;;;AAqBA,MAAM,GAAA,GAAM,aAAa,UAAU,CAAA,CAAA;AAsBtB,MAAA,QAAA,GAA8B,CAAC,KAAU,KAAA;AAClD,EAAA,MAAM,OAAO,OAAQ,EAAA,CAAA;AAErB,EAAA,MAAM,EAAE,KAAA,EAAO,WAAc,GAAA,MAAA,EAAW,GAAA,KAAA,CAAA;AACxC,EAAA,MAAM,EAAE,cAAA,E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C,UAAA,EAAY,aAAa,CAAA,GAAI,SAAyC,KAAS,CAAA,CAAA,CAAA;AAEtF,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,IAAI,CAAC,GAAK,EAAA;AACN,MAAA,OAAA;AAAA,KACJ;AAEA,IAAA,MAAMA,WAAa,GAAA,IAAI,kBAAmB,CAAA,GAAA,CAAI,OAAO,eAAiB,EAAA;AAAA,MAClE,aAAa,IAAK,CAAA,aAAA,CAAc,EAAE,EAAA,EAAI,eAAe,CAAA;AAAA,KACxD,CAAA,CAAA;AACD,IAAA,aAAA,CAAcA,WAAU,CAAA,CAAA;AAExB,IAAA,OAAO,MAAM;AACT,MAAAA,YAAW,OAAQ,EAAA,CAAA;AACnB,MAAA,aAAA,CAAc,KAAS,CAAA,CAAA,CAAA;AAAA,KAC3B,CAAA;AAAA,GACD,EAAA,CAAC,GAAK,EAAA,IAAA,EAAM,eAAe,CAAC,CAAA,CAAA;AAE/B,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,UAAA,EAAY,eAAe,WAAW,CAAA,CAAA;AAAA,GACvC,EAAA,CAAC,UAAY,EAAA,WAAW,CAAC,CAAA,CAAA;AAE5B,EAAO,OAAA,UAAA,CAAA;AACX;;;;"}
|
|
1
|
+
{"version":3,"file":"Printing.js","sources":["Printing.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n Box,\n Button,\n FormControl,\n FormLabel,\n HStack,\n Input,\n Select\n} from \"@open-pioneer/chakra-integration\";\nimport { createLogger } from \"@open-pioneer/core\";\nimport { MapModel, useMapModel } from \"@open-pioneer/map\";\nimport { NotificationService } from \"@open-pioneer/notifier\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { FC, FormEvent, useEffect, useState } from \"react\";\nimport { FileFormatType, PrintingController } from \"./PrintingController\";\nimport type { ViewPaddingBehavior, PrintingService } from \"./index\";\n\nconst LOG = createLogger(\"printing\");\n\n/**\n * This is special property for the Printing.\n */\nexport interface PrintingProps extends CommonComponentProps {\n /**\n * The id of the map.\n */\n mapId: string;\n\n /**\n * Whether to respect the map view's padding when printing (default: `\"auto\"`).\n *\n * See also {@link ViewPaddingBehavior}.\n */\n viewPadding?: ViewPaddingBehavior;\n}\n\n/**\n * The `Printing` component can be used to download the current map view as a printable file.\n */\nexport const Printing: FC<PrintingProps> = (props) => {\n const intl = useIntl();\n\n const { mapId, viewPadding = \"auto\" } = props;\n const { containerProps } = useCommonComponentProps(\"printing\", props);\n const [selectedFileFormat, setSelectedFileFormat] = useState<FileFormatType>(\"pdf\");\n const [title, setTitle] = useState<string>(\"\");\n const [running, setRunning] = useState<boolean>(false);\n\n const notifier = useService<NotificationService>(\"notifier.NotificationService\");\n\n const { map } = useMapModel(mapId);\n const controller = useController(map, intl, viewPadding);\n\n function changeFileFormat(fileFormat: string) {\n if (fileFormat === \"png\" || fileFormat === \"pdf\") {\n setSelectedFileFormat(fileFormat);\n }\n }\n\n function exportMap() {\n if (running || !controller) {\n return;\n }\n\n setRunning(true);\n controller\n .handleMapExport({\n title,\n fileFormat: selectedFileFormat\n })\n .catch((error) => {\n const errorMessage = intl.formatMessage({ id: \"printingFailed\" });\n notifier.notify({\n level: \"error\",\n message: errorMessage\n });\n LOG.error(\"Failed to print the map\", error);\n })\n .finally(() => {\n setRunning(false);\n });\n }\n\n return (\n <Box {...containerProps}>\n <Box\n as=\"form\"\n m={2}\n alignItems=\"center\"\n onSubmit={(e: FormEvent) => {\n e.preventDefault();\n exportMap();\n }}\n >\n <FormControl as={HStack} mb={2}>\n <FormLabel minWidth=\"82\" mb={1}>\n {intl.formatMessage({ id: \"title\" })}\n </FormLabel>\n <Input\n placeholder={intl.formatMessage({ id: \"input.placeholder\" })}\n value={title}\n onChange={(event) => {\n setTitle(event.target.value);\n }}\n autoFocus // eslint-disable-line jsx-a11y/no-autofocus\n />\n </FormControl>\n <FormControl as={HStack} mb={2}>\n <FormLabel minWidth=\"82\" mb={1}>\n {intl.formatMessage({ id: \"fileFormat\" })}\n </FormLabel>\n <Select\n value={selectedFileFormat}\n onChange={(e) => changeFileFormat(e.target.value)}\n className=\"printing-select\"\n >\n <option value={\"png\"}>PNG</option>\n <option value={\"pdf\"}>PDF</option>\n </Select>\n </FormControl>\n <Button\n isLoading={running}\n loadingText={intl.formatMessage({ id: \"printingMap\" })}\n disabled={running}\n mt={2}\n p={2}\n className=\"printing-export-button\"\n type=\"submit\"\n width=\"100%\"\n >\n {intl.formatMessage({ id: \"export\" })}\n </Button>\n </Box>\n </Box>\n );\n};\n\n/**\n * Create a PrintingController instance to export the map view.\n */\nfunction useController(\n map: MapModel | undefined,\n intl: PackageIntl,\n viewPadding: ViewPaddingBehavior\n) {\n const printingService = useService<PrintingService>(\"printing.PrintingService\");\n const [controller, setController] = useState<PrintingController | undefined>(undefined);\n\n useEffect(() => {\n if (!map) {\n return;\n }\n\n const controller = new PrintingController(map.olMap, printingService, {\n overlayText: intl.formatMessage({ id: \"printingMap\" })\n });\n setController(controller);\n\n return () => {\n controller.destroy();\n setController(undefined);\n };\n }, [map, intl, printingService]);\n\n useEffect(() => {\n controller?.setViewPadding(viewPadding);\n }, [controller, viewPadding]);\n\n return controller;\n}\n"],"names":["controller"],"mappings":";;;;;;;;;AAqBA,MAAM,GAAA,GAAM,aAAa,UAAU,CAAA,CAAA;AAsBtB,MAAA,QAAA,GAA8B,CAAC,KAAU,KAAA;AAClD,EAAA,MAAM,OAAO,OAAQ,EAAA,CAAA;AAErB,EAAA,MAAM,EAAE,KAAA,EAAO,WAAc,GAAA,MAAA,EAAW,GAAA,KAAA,CAAA;AACxC,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,YAAY,KAAK,CAAA,CAAA;AACpE,EAAA,MAAM,CAAC,kBAAA,EAAoB,qB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,CAAU,MAAM;AACZ,IAAA,IAAI,CAAC,GAAK,EAAA;AACN,MAAA,OAAA;AAAA,KACJ;AAEA,IAAA,MAAMA,WAAa,GAAA,IAAI,kBAAmB,CAAA,GAAA,CAAI,OAAO,eAAiB,EAAA;AAAA,MAClE,aAAa,IAAK,CAAA,aAAA,CAAc,EAAE,EAAA,EAAI,eAAe,CAAA;AAAA,KACxD,CAAA,CAAA;AACD,IAAA,aAAA,CAAcA,WAAU,CAAA,CAAA;AAExB,IAAA,OAAO,MAAM;AACT,MAAAA,YAAW,OAAQ,EAAA,CAAA;AACnB,MAAA,aAAA,CAAc,KAAS,CAAA,CAAA,CAAA;AAAA,KAC3B,CAAA;AAAA,GACD,EAAA,CAAC,GAAK,EAAA,IAAA,EAAM,eAAe,CAAC,CAAA,CAAA;AAE/B,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,UAAA,EAAY,eAAe,WAAW,CAAA,CAAA;AAAA,GACvC,EAAA,CAAC,UAAY,EAAA,WAAW,CAAC,CAAA,CAAA;AAE5B,EAAO,OAAA,UAAA,CAAA;AACX;;;;"}
|
package/PrintingController.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import OlMap from "ol/Map";
|
|
2
2
|
import { PrintingService, ViewPaddingBehavior } from "./index";
|
|
3
3
|
export type FileFormatType = "png" | "pdf";
|
|
4
|
+
export interface ExportOptions {
|
|
5
|
+
title?: string | undefined;
|
|
6
|
+
fileFormat: FileFormatType;
|
|
7
|
+
}
|
|
4
8
|
export declare class PrintingController {
|
|
5
9
|
private olMap;
|
|
6
|
-
private title;
|
|
7
|
-
private fileFormat;
|
|
8
10
|
private i18n;
|
|
9
11
|
private printingService;
|
|
10
12
|
private viewPadding;
|
|
@@ -12,10 +14,8 @@ export declare class PrintingController {
|
|
|
12
14
|
private overlay;
|
|
13
15
|
constructor(olMap: OlMap, printingService: PrintingService, i18n: I18n);
|
|
14
16
|
destroy(): void;
|
|
15
|
-
setTitle(title: string): void;
|
|
16
|
-
setFileFormat(format: FileFormatType): void;
|
|
17
17
|
setViewPadding(padding: ViewPaddingBehavior): void;
|
|
18
|
-
handleMapExport(): Promise<void>;
|
|
18
|
+
handleMapExport(options: ExportOptions): Promise<void>;
|
|
19
19
|
private begin;
|
|
20
20
|
private reset;
|
|
21
21
|
private getTitleAndFileName;
|
package/PrintingController.js
CHANGED
|
@@ -3,8 +3,6 @@ import { createBlockUserOverlay, canvasToPng } from './utils.js';
|
|
|
3
3
|
const DEFAULT_FILE_NAME = "map";
|
|
4
4
|
class PrintingController {
|
|
5
5
|
olMap;
|
|
6
|
-
title = "";
|
|
7
|
-
fileFormat = "pdf";
|
|
8
6
|
i18n;
|
|
9
7
|
printingService;
|
|
10
8
|
viewPadding;
|
|
@@ -18,17 +16,11 @@ class PrintingController {
|
|
|
18
16
|
destroy() {
|
|
19
17
|
this.reset();
|
|
20
18
|
}
|
|
21
|
-
setTitle(title) {
|
|
22
|
-
this.title = title;
|
|
23
|
-
}
|
|
24
|
-
setFileFormat(format) {
|
|
25
|
-
this.fileFormat = format;
|
|
26
|
-
}
|
|
27
19
|
setViewPadding(padding) {
|
|
28
20
|
this.viewPadding = padding;
|
|
29
21
|
}
|
|
30
|
-
async handleMapExport() {
|
|
31
|
-
if (!this.olMap
|
|
22
|
+
async handleMapExport(options) {
|
|
23
|
+
if (!this.olMap) {
|
|
32
24
|
return;
|
|
33
25
|
}
|
|
34
26
|
try {
|
|
@@ -39,7 +31,7 @@ class PrintingController {
|
|
|
39
31
|
});
|
|
40
32
|
const canvas = this.printMap.getCanvas();
|
|
41
33
|
if (canvas) {
|
|
42
|
-
|
|
34
|
+
options.fileFormat == "png" ? await this.exportMapInPNG(canvas, options) : await this.exportMapInPDF(canvas, options);
|
|
43
35
|
} else {
|
|
44
36
|
throw new Error("Canvas export failed");
|
|
45
37
|
}
|
|
@@ -57,12 +49,12 @@ class PrintingController {
|
|
|
57
49
|
this.overlay?.destroy();
|
|
58
50
|
this.overlay = void 0;
|
|
59
51
|
}
|
|
60
|
-
getTitleAndFileName() {
|
|
61
|
-
const titleValue =
|
|
62
|
-
const fileName =
|
|
52
|
+
getTitleAndFileName(options) {
|
|
53
|
+
const titleValue = options.title || "";
|
|
54
|
+
const fileName = options.title || DEFAULT_FILE_NAME;
|
|
63
55
|
return { title: titleValue, fileName };
|
|
64
56
|
}
|
|
65
|
-
async exportMapInPNG(mapCanvas) {
|
|
57
|
+
async exportMapInPNG(mapCanvas, options) {
|
|
66
58
|
const containerCanvas = document.createElement("canvas");
|
|
67
59
|
containerCanvas.width = mapCanvas.width;
|
|
68
60
|
containerCanvas.height = mapCanvas.height + 50;
|
|
@@ -71,7 +63,7 @@ class PrintingController {
|
|
|
71
63
|
if (!context) {
|
|
72
64
|
throw new Error("2d canvas rendering context not available");
|
|
73
65
|
}
|
|
74
|
-
const { title, fileName } = this.getTitleAndFileName();
|
|
66
|
+
const { title, fileName } = this.getTitleAndFileName(options);
|
|
75
67
|
context.fillStyle = "#fff";
|
|
76
68
|
context.fillRect(0, 0, containerCanvas.width, containerCanvas.height);
|
|
77
69
|
context.font = "20px bold sans-serif";
|
|
@@ -89,7 +81,7 @@ class PrintingController {
|
|
|
89
81
|
link.href = dataURL;
|
|
90
82
|
link.click();
|
|
91
83
|
}
|
|
92
|
-
async exportMapInPDF(canvas) {
|
|
84
|
+
async exportMapInPDF(canvas, options) {
|
|
93
85
|
const { jsPDF } = await import('jspdf');
|
|
94
86
|
const pdf = new jsPDF({
|
|
95
87
|
orientation: "landscape",
|
|
@@ -102,7 +94,7 @@ class PrintingController {
|
|
|
102
94
|
const mapOffset = 20;
|
|
103
95
|
const mapPageHeight = pageHeight - mapOffset;
|
|
104
96
|
pdf.setFontSize(20);
|
|
105
|
-
const { title, fileName } = this.getTitleAndFileName();
|
|
97
|
+
const { title, fileName } = this.getTitleAndFileName(options);
|
|
106
98
|
pdf.text(title, pageWidth / 2, titleOffset, { align: "center" });
|
|
107
99
|
const imageAspectRatio = canvas.width / canvas.height;
|
|
108
100
|
let targetImageHeight = mapPageHeight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrintingController.js","sources":["PrintingController.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport OlMap from \"ol/Map\";\nimport { PrintingService, PrintResult, ViewPaddingBehavior } from \"./index\";\nimport { canvasToPng, createBlockUserOverlay } from \"./utils\";\nimport { Resource } from \"@open-pioneer/core\";\n\nexport type FileFormatType = \"png\" | \"pdf\";\n\nconst DEFAULT_FILE_NAME = \"map\";\n\nexport class PrintingController {\n private olMap: OlMap;\n private title: string = \"\";\n private fileFormat: FileFormatType = \"pdf\";\n private i18n: I18n;\n\n private printingService: PrintingService;\n private viewPadding: ViewPaddingBehavior | undefined;\n\n private printMap: PrintResult | undefined = undefined;\n private overlay: Resource | undefined = undefined;\n\n constructor(olMap: OlMap, printingService: PrintingService, i18n: I18n) {\n this.olMap = olMap;\n this.printingService = printingService;\n this.i18n = i18n;\n }\n\n destroy() {\n this.reset();\n }\n\n setTitle(title: string) {\n this.title = title;\n }\n\n setFileFormat(format: FileFormatType) {\n this.fileFormat = format;\n }\n\n setViewPadding(padding: ViewPaddingBehavior) {\n this.viewPadding = padding;\n }\n\n async handleMapExport() {\n if (!this.olMap || !this.fileFormat) {\n return;\n }\n\n try {\n this.begin();\n this.printMap = await this.printingService.printMap(this.olMap, {\n blockUserInteraction: false,\n viewPadding: this.viewPadding\n });\n const canvas = this.printMap.getCanvas();\n if (canvas) {\n this.fileFormat == \"png\"\n ? await this.exportMapInPNG(canvas)\n : await this.exportMapInPDF(canvas);\n } else {\n throw new Error(\"Canvas export failed\");\n }\n } finally {\n this.reset();\n }\n }\n\n private begin() {\n const container = this.olMap.getTargetElement();\n if (container) {\n this.overlay = createBlockUserOverlay(container, this.i18n.overlayText);\n }\n }\n\n private reset() {\n this.overlay?.destroy();\n this.overlay = undefined;\n }\n\n private getTitleAndFileName() {\n const titleValue = this.title || \"\";\n const fileName = this.title || DEFAULT_FILE_NAME;\n return { title: titleValue, fileName: fileName };\n }\n\n private async exportMapInPNG(mapCanvas: HTMLCanvasElement) {\n const containerCanvas = document.createElement(\"canvas\");\n containerCanvas.width = mapCanvas.width;\n containerCanvas.height = mapCanvas.height + 50;\n containerCanvas.style.backgroundColor = \"#fff\";\n\n const context = containerCanvas.getContext(\"2d\");\n if (!context) {\n throw new Error(\"2d canvas rendering context not available\");\n }\n\n const { title, fileName } = this.getTitleAndFileName();\n\n context.fillStyle = \"#fff\"; // background color for background rect\n context.fillRect(0, 0, containerCanvas.width, containerCanvas.height); //draw background rect\n context.font = 20 + \"px bold sans-serif\";\n context.textAlign = \"center\";\n context.fillStyle = \"#000\"; // text color\n\n const x = containerCanvas.width / 2; //align text to center\n context.fillText(title, x, 20);\n context.drawImage(mapCanvas, 0, 50);\n\n const link = document.createElement(\"a\");\n link.setAttribute(\"download\", fileName + \".png\");\n\n const dataURL = canvasToPng(containerCanvas);\n if (!dataURL) {\n throw new Error(\"Failed to get image data URL\");\n }\n\n link.href = dataURL;\n link.click();\n }\n\n private async exportMapInPDF(canvas: HTMLCanvasElement) {\n // Landscape map export.\n // Lazy load pdfjs as well.\n const { jsPDF } = await import(\"jspdf\");\n const pdf = new jsPDF({\n orientation: \"landscape\",\n unit: \"mm\",\n format: \"a4\"\n });\n\n // Simple layout: 50 pixels for the header and\n // the remaining space can be used by the map export.\n const pageWidth = pdf.internal.pageSize.getWidth();\n const pageHeight = pdf.internal.pageSize.getHeight();\n const titleOffset = 15;\n const mapOffset = 20;\n const mapPageHeight = pageHeight - mapOffset;\n\n // Render title\n pdf.setFontSize(20);\n const { title, fileName } = this.getTitleAndFileName();\n pdf.text(title, pageWidth / 2, titleOffset, { align: \"center\" });\n\n // Resize image while keeping aspect ratio\n const imageAspectRatio = canvas.width / canvas.height;\n let targetImageHeight = mapPageHeight;\n let targetImageWidth = targetImageHeight * imageAspectRatio;\n if (targetImageWidth >= pageWidth) {\n targetImageWidth = pageWidth;\n targetImageHeight = targetImageWidth / imageAspectRatio;\n }\n\n // Center image\n const imageX = (pageWidth - targetImageWidth) / 2;\n const imageY = mapOffset + (mapPageHeight - targetImageHeight) / 2;\n\n pdf.addImage(canvas, \"\", imageX, imageY, targetImageWidth, targetImageHeight);\n pdf.save(fileName + \".pdf\");\n }\n}\n\ninterface I18n {\n overlayText: string;\n}\n"],"names":[],"mappings":";;AASA,MAAM,iBAAoB,GAAA,KAAA,CAAA;AAEnB,MAAM,kBAAmB,CAAA;AAAA,EACpB,KAAA,CAAA;AAAA,EACA,KAAgB,GAAA,EAAA,CAAA;AAAA,EAChB,UAA6B,GAAA,KAAA,CAAA;AAAA,EAC7B,IAAA,CAAA;AAAA,EAEA,eAAA,CAAA;AAAA,EACA,WAAA,CAAA;AAAA,EAEA,QAAoC,GAAA,KAAA,CAAA,CAAA;AAAA,EACpC,OAAgC,GAAA,KAAA,CAAA,CAAA;AAAA,EAExC,WAAA,CAAY,KAAc,EAAA,eAAA,EAAkC,IAAY,EAAA;AACpE,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,IAAA,CAAK,eAAkB,GAAA,eAAA,CAAA;AACvB,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA,CAAA;AAAA,GAChB;AAAA,EAEA,OAAU,GAAA;AACN,IAAA,IAAA,CAAK,KAAM,EAAA,CAAA;AAAA,GACf;AAAA,EAEA,SAAS,KAAe,EAAA;AACpB,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AAAA,GACjB;AAAA,EAEA,cAAc,MAAwB,EAAA;AAClC,IAAA,IAAA,CAAK,UAAa,GAAA,MAAA,CAAA;AAAA,GACtB;AAAA,EAEA,eAAe,OAA8B,EAAA;AACzC,IAAA,IAAA,CAAK,WAAc,GAAA,OAAA,CAAA;AAAA,GACvB;AAAA,EAEA,MAAM,eAAkB,GAAA;AACpB,IAAA,IAA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CAAA,KAAA,GAAQ,MAAO,CAAA,MAAA,CAAA;AAC/C,IAAA,IAAI,iBAAoB,GAAA,aAAA,CAAA;AACxB,IAAA,IAAI,mBAAmB,iBAAoB,GAAA,gBAAA,CAAA;AAC3C,IAAA,IAAI,oBAAoB,SAAW,EAAA;AAC/B,MAAmB,gBAAA,GAAA,SAAA,CAAA;AACnB,MAAA,iBAAA,GAAoB,gBAAmB,GAAA,gBAAA,CAAA;AAAA,KAC3C;AAGA,IAAM,MAAA,MAAA,GAAA,CAAU,YAAY,gBAAoB,IAAA,CAAA,CAAA;AAChD,IAAM,MAAA,MAAA,GAAS,SAAa,GAAA,CAAA,aAAA,GAAgB,iBAAqB,IAAA,CAAA,CAAA;AAEjE,IAAA,GAAA,CAAI,SAAS,MAAQ,EAAA,EAAA,EAAI,MAAQ,EAAA,MAAA,EAAQ,kBAAkB,iBAAiB,CAAA,CAAA;AAC5E,IAAI,GAAA,CAAA,IAAA,CAAK,WAAW,MAAM,CAAA,CAAA;AAAA,GAC9B;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"PrintingController.js","sources":["PrintingController.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport OlMap from \"ol/Map\";\nimport { PrintingService, PrintResult, ViewPaddingBehavior } from \"./index\";\nimport { canvasToPng, createBlockUserOverlay } from \"./utils\";\nimport { Resource } from \"@open-pioneer/core\";\n\nexport type FileFormatType = \"png\" | \"pdf\";\n\nconst DEFAULT_FILE_NAME = \"map\";\n\nexport interface ExportOptions {\n title?: string | undefined;\n fileFormat: FileFormatType;\n}\n\nexport class PrintingController {\n private olMap: OlMap;\n private i18n: I18n;\n\n private printingService: PrintingService;\n private viewPadding: ViewPaddingBehavior | undefined;\n\n private printMap: PrintResult | undefined = undefined;\n private overlay: Resource | undefined = undefined;\n\n constructor(olMap: OlMap, printingService: PrintingService, i18n: I18n) {\n this.olMap = olMap;\n this.printingService = printingService;\n this.i18n = i18n;\n }\n\n destroy() {\n this.reset();\n }\n\n setViewPadding(padding: ViewPaddingBehavior) {\n this.viewPadding = padding;\n }\n\n async handleMapExport(options: ExportOptions) {\n if (!this.olMap) {\n return;\n }\n\n try {\n this.begin();\n this.printMap = await this.printingService.printMap(this.olMap, {\n blockUserInteraction: false,\n viewPadding: this.viewPadding\n });\n const canvas = this.printMap.getCanvas();\n if (canvas) {\n options.fileFormat == \"png\"\n ? await this.exportMapInPNG(canvas, options)\n : await this.exportMapInPDF(canvas, options);\n } else {\n throw new Error(\"Canvas export failed\");\n }\n } finally {\n this.reset();\n }\n }\n\n private begin() {\n const container = this.olMap.getTargetElement();\n if (container) {\n this.overlay = createBlockUserOverlay(container, this.i18n.overlayText);\n }\n }\n\n private reset() {\n this.overlay?.destroy();\n this.overlay = undefined;\n }\n\n private getTitleAndFileName(options: ExportOptions) {\n const titleValue = options.title || \"\";\n const fileName = options.title || DEFAULT_FILE_NAME;\n return { title: titleValue, fileName: fileName };\n }\n\n private async exportMapInPNG(mapCanvas: HTMLCanvasElement, options: ExportOptions) {\n const containerCanvas = document.createElement(\"canvas\");\n containerCanvas.width = mapCanvas.width;\n containerCanvas.height = mapCanvas.height + 50;\n containerCanvas.style.backgroundColor = \"#fff\";\n\n const context = containerCanvas.getContext(\"2d\");\n if (!context) {\n throw new Error(\"2d canvas rendering context not available\");\n }\n\n const { title, fileName } = this.getTitleAndFileName(options);\n\n context.fillStyle = \"#fff\"; // background color for background rect\n context.fillRect(0, 0, containerCanvas.width, containerCanvas.height); //draw background rect\n context.font = 20 + \"px bold sans-serif\";\n context.textAlign = \"center\";\n context.fillStyle = \"#000\"; // text color\n\n const x = containerCanvas.width / 2; //align text to center\n context.fillText(title, x, 20);\n context.drawImage(mapCanvas, 0, 50);\n\n const link = document.createElement(\"a\");\n link.setAttribute(\"download\", fileName + \".png\");\n\n const dataURL = canvasToPng(containerCanvas);\n if (!dataURL) {\n throw new Error(\"Failed to get image data URL\");\n }\n\n link.href = dataURL;\n link.click();\n }\n\n private async exportMapInPDF(canvas: HTMLCanvasElement, options: ExportOptions) {\n // Landscape map export.\n // Lazy load pdfjs as well.\n const { jsPDF } = await import(\"jspdf\");\n const pdf = new jsPDF({\n orientation: \"landscape\",\n unit: \"mm\",\n format: \"a4\"\n });\n\n // Simple layout: 50 pixels for the header and\n // the remaining space can be used by the map export.\n const pageWidth = pdf.internal.pageSize.getWidth();\n const pageHeight = pdf.internal.pageSize.getHeight();\n const titleOffset = 15;\n const mapOffset = 20;\n const mapPageHeight = pageHeight - mapOffset;\n\n // Render title\n pdf.setFontSize(20);\n const { title, fileName } = this.getTitleAndFileName(options);\n pdf.text(title, pageWidth / 2, titleOffset, { align: \"center\" });\n\n // Resize image while keeping aspect ratio\n const imageAspectRatio = canvas.width / canvas.height;\n let targetImageHeight = mapPageHeight;\n let targetImageWidth = targetImageHeight * imageAspectRatio;\n if (targetImageWidth >= pageWidth) {\n targetImageWidth = pageWidth;\n targetImageHeight = targetImageWidth / imageAspectRatio;\n }\n\n // Center image\n const imageX = (pageWidth - targetImageWidth) / 2;\n const imageY = mapOffset + (mapPageHeight - targetImageHeight) / 2;\n\n pdf.addImage(canvas, \"\", imageX, imageY, targetImageWidth, targetImageHeight);\n pdf.save(fileName + \".pdf\");\n }\n}\n\ninterface I18n {\n overlayText: string;\n}\n"],"names":[],"mappings":";;AASA,MAAM,iBAAoB,GAAA,KAAA,CAAA;AAOnB,MAAM,kBAAmB,CAAA;AAAA,EACpB,KAAA,CAAA;AAAA,EACA,IAAA,CAAA;AAAA,EAEA,eAAA,CAAA;AAAA,EACA,WAAA,CAAA;AAAA,EAEA,QAAoC,GAAA,KAAA,CAAA,CAAA;AAAA,EACpC,OAAgC,GAAA,KAAA,CAAA,CAAA;AAAA,EAExC,WAAA,CAAY,KAAc,EAAA,eAAA,EAAkC,IAAY,EAAA;AACpE,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,IAA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CAAA;AACpB,IAAA,MAAM,SAAY,GAAA,EAAA,CAAA;AAClB,IAAA,MAAM,gBAAgB,UAAa,GAAA,SAAA,CAAA;AAGnC,IAAA,GAAA,CAAI,YAAY,EAAE,CAAA,CAAA;AAClB,IAAA,MAAM,EAAE,KAAO,EAAA,QAAA,EAAa,GAAA,IAAA,CAAK,oBAAoB,OAAO,CAAA,CAAA;AAC5D,IAAI,GAAA,CAAA,IAAA,CAAK,OAAO,SAAY,GAAA,CAAA,EAAG,aAAa,EAAE,KAAA,EAAO,UAAU,CAAA,CAAA;AAG/D,IAAM,MAAA,gBAAA,GAAmB,MAAO,CAAA,KAAA,GAAQ,MAAO,CAAA,MAAA,CAAA;AAC/C,IAAA,IAAI,iBAAoB,GAAA,aAAA,CAAA;AACxB,IAAA,IAAI,mBAAmB,iBAAoB,GAAA,gBAAA,CAAA;AAC3C,IAAA,IAAI,oBAAoB,SAAW,EAAA;AAC/B,MAAmB,gBAAA,GAAA,SAAA,CAAA;AACnB,MAAA,iBAAA,GAAoB,gBAAmB,GAAA,gBAAA,CAAA;AAAA,KAC3C;AAGA,IAAM,MAAA,MAAA,GAAA,CAAU,YAAY,gBAAoB,IAAA,CAAA,CAAA;AAChD,IAAM,MAAA,MAAA,GAAS,SAAa,GAAA,CAAA,aAAA,GAAgB,iBAAqB,IAAA,CAAA,CAAA;AAEjE,IAAA,GAAA,CAAI,SAAS,MAAQ,EAAA,EAAA,EAAI,MAAQ,EAAA,MAAA,EAAQ,kBAAkB,iBAAiB,CAAA,CAAA;AAC5E,IAAI,GAAA,CAAA,IAAA,CAAK,WAAW,MAAM,CAAA,CAAA;AAAA,GAC9B;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/printing",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "This package provides a UI component to export the current map view as a printable file.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"directory": "src/packages/printing"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@open-pioneer/chakra-integration": "^1.1.
|
|
18
|
-
"@open-pioneer/
|
|
19
|
-
"@open-pioneer/
|
|
20
|
-
"@open-pioneer/
|
|
21
|
-
"@open-pioneer/
|
|
22
|
-
"ol": "^9.2.4",
|
|
23
|
-
"react": "^18.3.1",
|
|
17
|
+
"@open-pioneer/chakra-integration": "^1.1.4",
|
|
18
|
+
"@open-pioneer/core": "^1.3.0",
|
|
19
|
+
"@open-pioneer/notifier": "^0.3.6",
|
|
20
|
+
"@open-pioneer/react-utils": "^1.0.1",
|
|
21
|
+
"@open-pioneer/runtime": "^2.1.7",
|
|
24
22
|
"classnames": "^2.3.2",
|
|
25
23
|
"html2canvas": "^1.4.1",
|
|
26
24
|
"jspdf": "^2.5.1",
|
|
27
|
-
"
|
|
25
|
+
"ol": "^9.2.4",
|
|
26
|
+
"react": "^18.3.1",
|
|
27
|
+
"@open-pioneer/map": "^0.6.1"
|
|
28
28
|
},
|
|
29
29
|
"exports": {
|
|
30
30
|
"./package.json": "./package.json",
|