Agraph: Saving to PDF Functionality

Hello! I have successfully created a graph using the Agraph library and was wondering if there was a way to save just the graph as an pdf (or an Image, I can do post processing later) without using browser tools, such as right click and save image as. My best efforts are pointing me towards Selenium, and I wanted to know if there was an alternative before I embark on that journey.