Previewing PDF in script

I’m making a script to generate PDF. Is there an interface for previewing PDF content before I print, just like the print preview provided by glyph software (Command + P)

Do you print from Glyphs directly? You just open the pdf in Preview.app.

I used Python to importdrawbot and wrote a script to generate a PDF according to the requirements. However, I want to add a function, that is, before save as PDF , preview the PDF, and then decide whether to save it.
In other words, can Icreate a preview control use vanilla?

You can use an NSImageView to display a PDF (make a NSImage from the pdf).

ok,I try it,thanks.