question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When to know each job is currently being printed?

See original GitHub issue

Hi, not sure if there is a way to know when to find out when each job is currently printing? So I can say something like this?

    pdfDocs.forEach((pdf, index) => {
      ptp
        .print(pdf.path, options(pdf.tray))
        .then(console.log)
        .catch(console.error, "err");
      setText(`Printing pack ${index + 1} of ${pdfDocs.length}`);
    });
  };

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Aug 6, 2021

oo okay, amazing, thank you 😃

1reaction
artiebitscommented, Aug 6, 2021

hi @KirstLMCG this package is not responsible for downloading PDF, only printing it. But you can do something like this to download a PDF, print it, and then delete it.

const fs = require("fs");
const path = require("path");
const printer = require("pdf-to-printer");
const fetch = require("node-fetch");

// Download a PDF
fetch(urlToPdf)
  .then((res) => res.buffer())
  .then((buffer) => {
    // Save it
    const pdf = save(buffer);

    // Print it
    printer
      .print(pdf)
      .then(console.log)
      .catch(console.error)
      // Delete it
      .finally(() => remove(pdf));
  });

function save(buffer) {
  const pdfPath = path.join(__dirname, randomString() + ".pdf");
  fs.writeFileSync(pdfPath, buffer, "binary");
  return pdfPath;
}

function remove(pdf) {
  fs.unlinkSync(pdf);
}

function randomString() {
  return Math.random().toString(36).substring(7);
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to view details of current and completed print jobs on ...
View the job ... To see what is currently printing, click that Printer icon in your Dock. Alternatively, you can open System Preferences...
Read more >
How to: Discover Whether a Print Job Can Be ...
Learn how the PrintQueue and PrintSystemJobInfo classes provide a means for checking whether a given print job can print on a given queue...
Read more >
Check on a printer or print job using the Dock on Mac
To see information about print jobs, choose Jobs > Quick Look Job, Jobs > Show My Jobs, or Jobs > Show Everyone's Jobs....
Read more >
How to check if a print job was sent to your printer
Once the new menu loads, pick the Printers & Scanners option from the menu on the left. Click on the printer you would...
Read more >
Checking the status of a print job (qchk command)
You can use the qchk command to check the status of a print job. For local print jobs, the printer must be physically...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found