Текст не отображается, таблица и изображения видны после загрузки pdf с сервера с помощью alamofire - PullRequest
0 голосов
/ 05 февраля 2019

Функция, которую я вызываю для загрузки файла с сервера, может быть найдена ниже.Я пробовал разные решения alamofire, чтобы загрузить и сохранить файл PDF.Файл сохраняется в локальном каталоге, но проблема заключается в следующем: когда я открыл файл, он показывает мне pdf-файл с таблицей и изображениями, но не показывает мне текст.

func downloadPDFPacket(PacketUrl : String,PacketName : String,AgendaID : Int,MeetingID : Int){

    Alamofire.request("\(PacketUrl)").downloadProgress(closure : { (progress) in
        print(progress.fractionCompleted)

    }).responseData{ (response) in
        print(response)
        print("value---",response.result.value!)
        print("desc---",response.result.description)
        //let randomString = NSUUID().uuidString
        response.result.ifSuccess {
            print("data---",response.data)
            if let data = response.result.value {

                let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) as Array
                let documentDirectory = paths[0] as NSString
                let path = documentDirectory.appendingPathComponent("\(PacketName)\("_")\(UserDefaults.standard.getUserID())\("_")\(AgendaID)\(".pdf")")

                let fileManager = FileManager.default
                if(!fileManager.fileExists(atPath: path)){
                    let documentsURL = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first!
                    let documentSavePath = documentsURL.appendingPathComponent("\(PacketName)\("_")\(UserDefaults.standard.getUserID())\("_")\(AgendaID)\(".pdf")")
                    do {
                        print("final data-----",response.data)
                        try response.data?.write(to: documentSavePath, options: .atomic)
                        //try data.write(to: documentSavePath, options: .atomic)
                        DispatchQueue.main.async {
                            self.onComplete?("Success")
                            self.updateAgendaMeetingDetailCount(AgendaId: AgendaID)
                            self.updateMeetingDownloadPacketCount(MeetingId: MeetingID)
                        }
                    } catch {
                        print("Something went wrong!")
                    }
                }else{
                    self.onComplete("Already Exits")

                }
            }
        }
    }
}
...