Salesforce.com makes it extremely easy to generate PDF documents on the fly by simply using the renderAs="pdf" attribute for the component. It's also a snap to attach these PDFs to records as Attachments. Below is a small Visualforce page and Controller that generates a PDF and saves it to an Account.</p>
Note: there is a small issue when it comes to testing the Controller. Salesforce currently throws an error (Salesforce.com Error "Unable to retrieve object") when getContent or getContentAsPDF is called from a test method. There's an Idea to make this work properly. I encourage everyone to vote for this.
PdfGenerator Visualforce Page
The Visualforce page allows the users to enter the ID of the Account to attach the PDF to as well as the name of the PDF. You could just have easily used a Controller Extension instead of entering the ID for the Account but I went this route for simplicity.
PdfGeneratorController Custom Controller
The Controller passes the Account ID that the user entered as a parameter for the Visualforce page being generated. It then creates a new Attachment object and sets some attributes. It sets the ParentId to the value of the Account ID that the user entered so that the PDF is attached to that record. The Body of the attachment uses the Blob returned from the PageReference's getContent method. You could also use the getContentAsPDF method which always returns the page as a PDF, regardless of the component's renderAs attribute. However, this method always seems to throw an error in the test class. See the PageReference documentation for more info. The method then redirects the user to the Account page so they can view the PDF attachment.</p>
PdfGeneratorTemplate Visualforce Page
This is the Visualforce page that is generated in the Controller. It simply uses the StandardController and displays the Account name for the ID passed to it.