Send a PDF to the printer.

  • 1
  • Question
  • Updated 1 year ago
  • Answered
I already have a bunch of attachment records that have pdf attached to them.

so what I need to do is to be able to show a table (which I can do) and allow the user to print them in a batch.

I.e.  from the table they should be able to select all, or just of few of the records and hit the [PRINT] button and the code should print the selected pdf of the records selected.

Has anybody have sample code for sending pdfs to the printer from within skuid?

Thanks in advance.
Photo of Sofware Developer Guy

Sofware Developer Guy

  • 1,354 Points 1k badge 2x thumb

Posted 1 year ago

  • 1
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi SDG,

To let users select specific records, I would recommend setting up a mass action on the table that uses the action "Remove row(s) from Model." This would take the selected rows out of the page's model - it wouldn't delete them, but they'd be removed from the current table. 

My first thought would be to make use of filters on the table to allow users to build their desired list. There isn't an action in Skuid's action framework for printing, but, you could easily add a snippet and run that as part of an action sequence. The simple Javascript code print() will open the browser's print dialog. The real trick will be to style your Skuid page in a way that will be printer-friendly, using themes or custom CSS
Photo of Sofware Developer Guy

Sofware Developer Guy

  • 1,354 Points 1k badge 2x thumb
Thanks for the reply Mark!

I already have the pdfs generated in the Attachment object.  All I need is a mechanism to send them to the printer.   Preferably without any user intervention.  

What I was envisioning was a table that showed a list of Attachment Records with a checkbox  fro selecting the records to be printed and some other info relating to the attachement.  There will be a button on the page that prints selected pdfs.

When the user clicks on the button, some code will run to send all of the pre-generated PDFS to the printer.  Sending the pdfs to the printer code (without user intervention) is what I am missing.

Thanks.
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
I see what you're after. Skuid doesn't have a declarative way to do this, so it sounds like you would need to dig further into custom scripting, and find out if it's possible to spool documents to the printer via Javascript. 
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
This post reviews a way to do it in APEX. You could probably convert this to invocable apex and pass in the ID's from Skuid. With mass update you could probably "adopt rows" into a twin model. That would allow you to have just the selected rows in a model. Then you could collect the ID's from that twin model and pass them as an invocable variable to your invocable Apex.

https://developer.salesforce.com/blog...
Photo of Sofware Developer Guy

Sofware Developer Guy

  • 1,354 Points 1k badge 2x thumb
Thanks Raymond,
Very cool solution for generating PDFs, which I may try later, however I already have the PDF code generation done.

I need to be able to send them to the printer without user intervention.  Any thoughts on that.  

Thanks again.  
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
You may be able to write a javascript snippet that loops through the records in the "twin" model I discuss above and then do something like this:
https://stackoverflow.com/questions/1...