DocuSign Base64 PDF转换问题

时间:2018-03-15 18:09:06

标签: java base64 docusignapi

发送基本64位PDF字节时出现File fFile = new File(pDFFileName); byte[] bBytes = FileUtils.readFileToByteArray(fFile); byte[] bBytesEnc = Base64.getEncoder().encode(bBytes); documents.setPDFBytes(bBytesEnc); 错误     DocuSign SOAP API(createAndSendEnvelope)。请帮我解决这个问题。

以下是将PDF文件转换为基本64字节的代码:

cordova plugin add

2 个答案:

答案 0 :(得分:1)

我认为你不需要做字节数组的Base64。我有以下代码没有base64,它对我来说很好:

        File f = new File(pDFFileName); 

        FileInputStream fs = new FileInputStream(f);
        byte[] pdfBytes = new byte[(int) f.length()];
        fs.read(pdfBytes);
        fs.close();
        Document doc = new Document();
        doc.setPDFBytes(pdfBytes);

答案 1 :(得分:0)

byte[] fileBytes = System.IO.File.ReadAllBytes(@"C:\Users\%username%\Desktop\File.PDF"); // Add a document to the envelope Document doc = new Document(); doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes); doc.Name = "TestFile.pdf"; doc.DocumentId = "3";

我这样做,这对我有用。