     }
     
     @IBAction func viewAttachment(_ sender: UIButton) {
+        var attachmentUrl = URL(string: content.attachment!.attachmentUrl)!
         if attachmentUrl.scheme == "http" {
             attachmentUrl = URL(string: "https://" + attachmentUrl.host! + attachmentUrl.path
-                + "?" + attachmentUrl.query!)
+                + "?" + attachmentUrl.query!)!
         }
         present(alertController, animated: false, completion: {
-            self.loadPdf()
+            self.loadPdf(url: attachmentUrl)
         })
     }
     
-    func loadPdf() {
-        let pdfDocument = PDFDocument(url: attachmentUrl!)
+    func loadPdf(url: URL) {
+        let pdfDocument = PDFDocument(url: url)
         alertController.dismiss(animated: false, completion: {
             self.displayPdf(pdfDocument)
         })

    @IBOutlet weak var bookmarkAnimationContainer: UIView!
    
    var content: Content!
    var attachmentUrl: URL!
    var bookmark: Bookmark!
    var position: Int!
    var loading: Bool = false

    }
    
    @IBAction func downloadAttachment(_ sender: UIButton) {
        var attachmentUrl = URL(string: content.attachment!.attachmentUrl)!
        UIApplication.shared.openURL(attachmentUrl)
        createContentAttempt()
    }
