let filePath = ... //URL of the PDF
let fileData = try Data.init(contentsOf: filePath!)
let fileStream:String = fileData.base64EncodedString(options: NSData.Base64EncodingOptions.init(rawValue: 0))
let url1 = Bundle.main.url(forResource: "pdffilename without extension", withExtension: "pdf")
let one1 = NSData(contentsOf: url1!)
let pdfstring:String = one1!.base64EncodedString(options: .endLineWithLineFeed)
print(pdfstring)
let filePath = "" // real path of the pdf file
let fileData = NSData(contentsOfFile: path)
let fileStream = data.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength) // base64 string
4条答案
按热度按时间ie3xauqp1#
斯威夫特3.x
oxalkeyp2#
拖动pdf文件到工程或五条路径前按住
ssgvzors3#
bzzcjhmw4#
你会在哪里选择文件,该文件路径必须给出:
1.首先生成base64字符串,然后使用它
1.然后生成字节
哪一个舒服都用得上。