def save_view_to_png()
#
path = UI.savepanel("Save PNG Image As","write_image.png")
return unless path
view = Sketchup.active_model.active_view
view.write_image(
filename: path,
width: view.vpwidth,
height: view.vpheight,
antialias: true,
transparent: true
)
#
end
But as @dezmo shows you can specify many more PDF export options
by using Sketchup::Model#export() (see the exports options for PDF document.)