Printing a Root Container into PDF

Hi!
I need to be able to print a root container into PDF. I have come across the function
system.print.createImage

https://support.inductiveautomation.com/usermanuals/ignition/index.html?system_print_printtoimage.htm

However, I don’t have any idea on how to use javax.imageio.ImageIO. Can someone please advice me on how to do this?

Thank you in advance!

The way I understand it is that function will save the snapshot of the current container. If you add a button and change the action to that function it will allow you to save that image.

If what you are wanting to do is have a picture of your container. Press Print Screen ( it may say Prt Scrn) its usually in the top right hand corner of the keyboard. Then open your imaged editor of choice and crop the picture down.

Assuming the ultimate goal is a printout that looks like a window, I would use the system.print.createPrintJob scripting function (see the example code on the page), and then use a ‘Print to PDF’ driver to save the output. This should result in output that looks like the attached:

Hi. Thanks for your responses.
Sorry for not being so clear with my question.

What I am hoping to do is to have a button, which is, when pressed, will create a print screen of a container and convert them to bytes so that I can save it as a BLOB field in our database.
Simultaneously, it will open a window browser for me to be able to save the file into PDF in a chosen location.

The part in which I’m having confusion is on how I can use javax.imageio.ImageIO to turn a a Java BufferedImage into bytes for BLOB. I am able to use this function ImageIO.write(createImage(getParentWindow(event).parent), 'jpg', baos) to create a jpg, but I am clueless on the code I should use to convert it to bytes.

Thank you in advance.