         rep.size = self.size
         let data = rep.representation(using: .PNG, properties: [:])
         return data!
+    }
+
+    func pdfData() -> Data {
+        let document = PDFDocument()
+        let page = PDFPage(image: self)!
+        document.insert(page, at: 0)
+        return document.dataRepresentation()!
     }
 }
 

            return [iconComponent]
        }

        dragPromisedFiles(ofTypes: ["png"],
                          from: CGRect(x: start.x - 26, y: start.y - 12, width: 32, height: 32),
                          source: self, slideBack: true, event: downEvent)


        return true
    }

    func save(_ data: Data, to destination: URL, withExtension pathExtension: String) throws -> String {
        let name = self.name.replacingOccurrences(of: "/", with: "-")
        var filename = name + "." + pathExtension
        var num = 1
        var url = destination.appendingPathComponent(filename)
        while (try? url.checkResourceIsReachable()) == true {
            num += 1
            filename = "\(name) \(num).\(pathExtension)"
            url = destination.appendingPathComponent(filename)
        }
        try data.write(to: url)
        return filename
    }

    override func namesOfPromisedFilesDropped(atDestination dropDestination: URL) -> [String]? {
        Swift.print("dropDestination: \(dropDestination)")
        guard let image = self.image else { return nil }

        do {
            return try [
                self.save(image.pngData(), to: dropDestination, withExtension: "png"),
                self.save(image.pdfData(), to: dropDestination, withExtension: "pdf")
            ]
        }
        catch {
            return nil
