Coder Social home page Coder Social logo

Comments (8)

eduardocalixtokorp avatar eduardocalixtokorp commented on June 2, 2024

I made the following workaround:

export function printJsSuportMobile(printJsConfig: Configuration) {
  const isAndroidDevice = navigator.userAgent.match(/Android/i);
  if (isAndroidDevice) {
    const byteArray = Uint8Array.from(atob(printJsConfig.printable).split('').map(char => char.charCodeAt(0)));
    const blob = new Blob([byteArray], { type: 'application/pdf' });
    const blobUrl = URL.createObjectURL(blob);
    window.open(blobUrl, '_blank');
  } else {
    printJS(printJsConfig);
  }
}

Edit: Obviouly it is only for Android, but in iOS, printJS was working just fine

from print.js.

bhavinangular28 avatar bhavinangular28 commented on June 2, 2024

@eduardocalixtokorp ok thanks but the IOS Chrome browser is not working for mobile

from print.js.

eduardocalixtokorp avatar eduardocalixtokorp commented on June 2, 2024

@bhavinangular28 I see. I tested in the latest Safari version not in chrome, but probably you can alter the code above and test it. It'd be something like:

export function printJsSuportMobile(printJsConfig: Configuration) {
  const isAndroidDevice = navigator.userAgent.match(/Android/i);
  const isAppleDevice = (/iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream
  if (isAndroidDevice || isAppleDevice) {
    const byteArray = Uint8Array.from(atob(printJsConfig.printable).split('').map(char => char.charCodeAt(0)));
    const blob = new Blob([byteArray], { type: 'application/pdf' });
    const blobUrl = URL.createObjectURL(blob);
    window.open(blobUrl, '_blank');
  } else {
    printJS(printJsConfig);
  }
}

IDK if isAppleDevice works, just got it from a random stackoverflow.

from print.js.

bhavinangular28 avatar bhavinangular28 commented on June 2, 2024

@eduardocalixtokorp I want to change the name, I can do it and how will it be done

Screenshot_2

from print.js.

eduardocalixtokorp avatar eduardocalixtokorp commented on June 2, 2024

@bhavinangular28, probably something like this. I didn't worry about it at the time, but iframe seems to be a reasonable solution

from print.js.

bhavinangular28 avatar bhavinangular28 commented on June 2, 2024

@eduardocalixtokorp does not proper show the title

image

from print.js.

bhavinangular28 avatar bhavinangular28 commented on June 2, 2024

@eduardocalixtokorp any suggestion please help

from print.js.

eduardocalixtokorp avatar eduardocalixtokorp commented on June 2, 2024

@bhavinangular28 Maybe this

from print.js.

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.