Pdf 使用仅接受UTF的API上载到DropBOX

Pdf 使用仅接受UTF的API上载到DropBOX,pdf,itextsharp,dropbox,Pdf,Itextsharp,Dropbox,请帮助我,我正在memorystream中创建一个pdf,我想将此流作为utf字符串传递给dropbox API upload Put调用,我正在使用spring.social与dropbox通信 MemoryStream ms = new MemoryStream(); Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.G

请帮助我,我正在memorystream中创建一个pdf,我想将此流作为utf字符串传递给dropbox API upload Put调用,我正在使用spring.social与dropbox通信

            MemoryStream ms = new MemoryStream();
            Document document = new Document(PageSize.A4);
            PdfWriter writer = PdfWriter.GetInstance(document, ms);
            iTextSharp.text.Image img = text.Image.GetInstance(CurrRecipt.imgurl);
            writer.CloseStream = false;
            document.Open();
            document.Add(img);
            document.Close();
当我使用Encoding.GetString或Utf8.convert将流转换为字符串时,PDFI不可读。 我无法将其作为byte[]数组传递,因为我的spring rest框架无法将其转换为Http请求体


当我从磁盘将Pdf读入流并将该流转换为字符串并写入新的Pdf文件时,也观察到了相同的行为。

System.Text.Encoding.GetBytes方法用于将.Net的字符串实现转换为特定格式的原始字节数组。PDF是二进制文件,因此使用字符串转换器没有意义

当Dropbox这样说:

传入和传出Dropbox API的每个字符串都需要UTF-8编码

他们谈论的是你发送的命令本身,而不是数据。只要您坚持使用基本的较低的128 ASCII字符(英文字母、数字、标点符号等),那么您通常不必担心这一点,因为这些字符使用Unicode一对一映射,并且使用UTF-8以相同的方式表示