Comments (6)
I think you must try to print without header and footer there's an option for that.
from leaflet.browser.print.
Hey.
What is your tarked page size for print in the browser and what page size you want to print from the plugin?
from leaflet.browser.print.
onMapReady($event: L.Map) {
this.map = $event;
// Define your custom print options
const printOptions = {
title: 'Custom Print Title', // The title for the printed page
position: 'topright', // The position of the print control
pageSize: 'A4', // Specify the page size (e.g., 'A4', 'Letter', or custom dimensions)
printModes: ['Portrait', 'Landscape'], // Supported print modes
closePopupsOnPrint: true, // Close popups before printing
contentSelector: '.leaflet-container', // CSS selector for the content to be printed
};
L.control
.browserPrint({
// title: 'Print Map',
printOptions,
})
.addTo(this.map);
this.map.on('browser-print-start', (e: any) => {
const legend = this.createLegend();
legend.addTo(e.printMap);
});
}
I would like to set the page size for printing from the plugin to 'A4,' while maintaining the default page size for printing in the browser. It's worth noting that even when I use the custom cropping option to print a small section of the map, it consistently results in the content spanning across two pages on smaller computers.
from leaflet.browser.print.
The page size from the plugin is A4, which is bigger in dimentions then Letter(that you have in the browser).
This may happen dues to browser taking default size from the system/printer in use/manual changes before. Try setuping letter as a pageSize in the plugin, or use A4 but change the paper size in the browser print screen and compare the results.
Current JS code tries to enforce paper sie from the plugin into browser print logic via media css, but it's not always the case and works only from time to time.
from leaflet.browser.print.
I setup the plugin to use letter as the PageSize, but when I tried to print from the browser, with a paper size of letter and A4, the content still ended up spanning two pages.
onMapReady($event: L.Map) {
this.map = $event;
// Define your custom print options
const printOptions = {
title: 'Print Map', // The title for the printed page
position: 'topright', // The position of the print control
pageSize: 'Letter', // Specify the page size (e.g., 'A4', 'Letter', or custom dimensions)
printModes: ['Portrait', 'Landscape'], // Supported print modes
closePopupsOnPrint: true, // Close popups before printing
contentSelector: '.leaflet-container', // CSS selector for the content to be printed
};
L.control.browserPrint({ printOptions }).addTo(this.map);
this.map.on('browser-print-start', (e: any) => {
const legend = this.createLegend();
legend.addTo(e.printMap);
});
}
Browser print screen for Letter |
Browser print screen for A4 |
from leaflet.browser.print.
This problem continues to persist in my work. I would appreciate it if you could respond when you have the opportunity. Thank you.
from leaflet.browser.print.
Related Issues (20)
- resize button heigth HOT 1
- work with React + TypeScript HOT 1
- Add dynamic contents(add new page if contents are huge), circle not printing. HOT 1
- ImageOverlay dont work
- JS error when manualMode is true HOT 1
- Printing two Leaflet instances (One only visible in printing) HOT 1
- Text of Leaflet Geoman Textlayer is not displayed HOT 2
- Offset with leaflet map position HOT 1
- Legend disappear when print ends HOT 1
- When defining custom printFunction, document.querySelector('.grid-print-container') does not include the Leaflet layers, only the container HOT 1
- package.json missing a main key HOT 2
- [Geotiff] Geotiff file on print HOT 5
- Fitting an Image as Watermark on PrintPage HOT 2
- Esri Vector Tile Printing? HOT 1
- Map Moves After Print Action HOT 3
- Problems with register L.nonTiledLayer.wms HOT 2
- Print additional content section on another page HOT 1
- Sometimes map overlay display blank before going into print mode. HOT 4
- Paper size calculations are incorrect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet.browser.print.