title: Save buffer as a *.pdf with `ns-write-file-using-panel` or similar option
body: <p>The existing code written by Rupert Swarbrick, later modified by Rory Yorke, still leaves open the need to specify the file location with a save-as function (e.g. on OSX, this would be <code>ns-write-file-using-panel</code>).  Does anyone have a suggestion, please, that adds an option similar to <code>ns-write-file-using-panel</code> and/or perhaps modifies the /tmp directory option written in the script?</p>
  
  <p><a href="https://stackoverflow.com/questions/7362625/word-wrap-for-emacs-print-buffer-to-pdf">Word wrap for Emacs print buffer to PDF</a></p>
  
  <p><a href="https://stackoverflow.com/questions/7442100/formatting-a-header-in-an-emacs-function-to-print-a-buffer-to-pdf-w-line-wrappi">Formatting a header in an Emacs function to print a buffer to PDF w/ line wrapping</a></p>
  
  <pre><code>(defun harden-newlines ()
    (interactive)
    "Make all the newlines in the buffer hard."
    (save-excursion
      (goto-char (point-min))
      (while (search-forward "\n" nil t)
        (backward-char)
        (put-text-property (point) (1+ (point)) 'hard t)
        (forward-char))))
  
  ;;    (defun spool-buffer-given-name (name)
  ;;      (load "ps-print")
  ;;      (let ((tmp ps-left-header))
  ;;        (unwind-protect
  ;;            (progn
  ;;              (setq ps-left-header
  ;;                    (list (lambda () name) 'ps-header-dirpart))
  ;;              (ps-spool-buffer-with-faces))
  ;;          (setf ps-left-header tmp))))
  
  (defun spool-buffer-given-name (name)
    (let ((ps-left-header (list (format "(%s)" name))))
      (ps-spool-buffer-with-faces)))
  
  (defun print-to-pdf ()
    "Print the current file to /tmp/print.pdf"
    (interactive)
    (let ((wbuf (generate-new-buffer "*Wrapped*"))
          (sbuf (current-buffer)))
      (jit-lock-fontify-now)
      (save-current-buffer
        (set-buffer wbuf)
        (insert-buffer sbuf)
  ;;      (longlines-mode t)
        (visual-line-mode t)
        (harden-newlines)
        (spool-buffer-given-name (buffer-name sbuf))
        (kill-buffer wbuf)
        (switch-to-buffer "*PostScript*")
        (write-file "/tmp/print.ps")
        (kill-buffer (current-buffer)))
      (call-process "ps2pdf14" nil nil nil
                    "/tmp/print.ps" "/tmp/print.pdf")
      (delete-file "/tmp/print.ps")
      (message "PDF saved to /tmp/print.pdf")))
  </code></pre>