Giter VIP home page Giter VIP logo

Comments (6)

Igor-Vladyka avatar Igor-Vladyka commented on June 21, 2024

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.

promisethedeveloper avatar promisethedeveloper commented on June 21, 2024
  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.

image

from leaflet.browser.print.

Igor-Vladyka avatar Igor-Vladyka commented on June 21, 2024

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.

promisethedeveloper avatar promisethedeveloper commented on June 21, 2024

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);
    });
  }
image
Browser print screen for Letter
image
Browser print screen for A4

from leaflet.browser.print.

promisethedeveloper avatar promisethedeveloper commented on June 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.