【问题标题】:Unable to send pdf generated by iText to docuSign无法将 iText 生成的 pdf 发送到 docuSign
【发布时间】:2014-02-25 13:01:07
【问题描述】:

我正在尝试在一个信封中发送两个 pdf 文件给 docusign。 pdf 是使用 iText 库生成的。仅在使用 iText 生成的 pdf 时才会出现此问题。其他(从网上下载的)pdf 在我的带有docusign 的应用程序中运行良好,因此java 代码没有问题。在信封内发送单个(iText 生成的)pdf 也没有问题。仅在发送多个(iText 生成的)pdf 文档时才会出现问题。在使用 docusign REST api 发送此 pdf 时,我收到 http 400 Bad Request 错误。谁能指出我的pdf中的问题。

这是我要发送的 pdf 的链接。

http://www.pdfhost.net/index.php?Action=Download&File=c8eeab729a8299e08e643d99afa00672 http://www.pdfhost.net/index.php?Action=Download&File=c8e0d2b8dfa9c2b82d10cc0503995310

提前致谢。

----- 编辑-----

在 Adob​​e Reader 中使用“另存为新 PDF”选项并保存文档后,我尝试了这两个文档。在此之后,这两个 pdf 文件成功上传到了docusign。有人可以帮助我解决 Adob​​e Reader 对我的文档所做的更改,使其与 docusign 一起使用。使用“另存为新的 pdf”选项后,pdf 的大小也增加了,快速 web 视图属性设置为 YES。

----- 编辑-----

这是我对文档签名的请求内容。这次使用 iText 生成的简单文本 pdf。此请求也会引发 400 Bad request 错误。

--BOUNDARY
Content-Type: application/json
Content-Disposition: form-data

{"status":"sent","emailBlurb":"email body","emailSubject":"email subject","documents":[{"documentId":"501","name":"cc5fda55_pdf","order":"1"},{"documentId":"502","name":"cc5fda56_pdf","order":"2"}],"recipients":{"signers":[{"recipientId":"74d5772d-6a5b-4fb0-b95d-947d8ecafd3c","returnUrl":null,"name":"Lucy Lu","email":"lucy.lu@gmail.com","clientUserId":"74d5772d-6a5b-4fb0-b95d-947d8ecafd3c","routingOrder":"1","tabs":{"signHereTabs":[{"documentId":"501","pageNumber":"1","anchorString":"ee_signature","anchorXOffset":"0","anchorYOffset":"0","anchorIgnoreIfNotPresent":"true","anchorUnits":"inches"},{"documentId":"502","pageNumber":"1","anchorString":"ee_signature","anchorXOffset":"0","anchorYOffset":"0","anchorIgnoreIfNotPresent":"true","anchorUnits":"inches"}]}}]}}
--BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="cc5fda55_pdf"; documentId=501

%PDF-1.4
%âãÏÓ
2 0 obj
<</Length 77/Filter/FlateDecode>>stream
<BYTE CONTENT HERE>
endstream
endobj
4 0 obj
<</Parent 3 0 R/Contents 2 0 R/Type/Page/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/Font<</F1 1 0 R>>>>/MediaBox[0 0 595 842]>>
endobj
1 0 obj
<</BaseFont/Helvetica/Type/Font/Encoding/WinAnsiEncoding/Subtype/Type1>>
endobj
3 0 obj
<</ITXT(5.0.6)/Type/Pages/Count 1/Kids[4 0 R]>>
endobj
5 0 obj
<</Type/Catalog/Pages 3 0 R>>
endobj
6 0 obj
<</Producer(iText 5.0.6 \(c\) 1T3XT BVBA)/ModDate(D:20140303192905+05'30')/CreationDate(D:20140303192905+05'30')>>
endobj
xref
0 7
0000000000 65535 f 
0000000315 00000 n 
0000000015 00000 n 
0000000403 00000 n 
0000000158 00000 n 
0000000466 00000 n 
0000000511 00000 n 
trailer
<</Root 5 0 R/ID [<e5359ec2954ce59003907592ee9885c4><af4ec60043c4444d2e7f07c3286e29da>]/Info 6 0 R/Size 7>>
startxref
641
%%EOF
--BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="cc5fda56_pdf"; documentId=502

%PDF-1.4
%âãÏÓ
2 0 obj
<</Length 77/Filter/FlateDecode>>stream
<BYTE CONTENT HERE>
endstream
endobj
4 0 obj
<</Parent 3 0 R/Contents 2 0 R/Type/Page/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/Font<</F1 1 0 R>>>>/MediaBox[0 0 595 842]>>
endobj
1 0 obj
<</BaseFont/Helvetica/Type/Font/Encoding/WinAnsiEncoding/Subtype/Type1>>
endobj
3 0 obj
<</ITXT(5.0.6)/Type/Pages/Count 1/Kids[4 0 R]>>
endobj
5 0 obj
<</Type/Catalog/Pages 3 0 R>>
endobj
6 0 obj
<</Producer(iText 5.0.6 \(c\) 1T3XT BVBA)/ModDate(D:20140303192905+05'30')/CreationDate(D:20140303192905+05'30')>>
endobj
xref
0 7
0000000000 65535 f 
0000000315 00000 n 
0000000015 00000 n 
0000000403 00000 n 
0000000158 00000 n 
0000000466 00000 n 
0000000511 00000 n 
trailer
<</Root 5 0 R/ID [<e5359ec2954ce59003907592ee9885c4><af4ec60043c4444d2e7f07c3286e29da>]/Info 6 0 R/Size 7>>
startxref
641
%%EOF

--BOUNDARY--

【问题讨论】:

  • pdfhost.net,正如@Bruno 已经详细描述的那样,目前似乎在操纵(实际上使)PDF 文档。因此,您可能希望使用更适合的文件托管程序来提供文件。此外,即使您的程序可以与其他 PDF 一起正常工作,它仍然可能是搜索错误的地方,从而提供有关您的代码调用 docusign 的更多信息。
  • 有人可以帮助我解决 Adob​​e Reader 对我的文档所做的更改,使其适用于 docusign。 - 如果您共享它们,这次使用文件共享服务不会破坏 pdf。

标签: itext docusignapi


【解决方案1】:

我已经测试了您的 PDF,并且我有证据表明问题不是由 iText 引起的,而是由使用 iText 创建 PDF 的人或提供 PDF 的服务引入的错误引起的。请在纯文本编辑器中打开文档。你会看到这个:

%PDF-1.4
%âãÏÓ
3 0 obj <</Length 236/Filter/FlateDecode>>stream
xœu‘?kÃ0Å÷û7¶Týq$y-´CK†€ CÈ+¶±kbòõ{’b‡  é~Ü{ÇC:ÇŽY¾bÊ¢;§ƒ
œ3®Ì
/ ñ›ú5ŽkØî8 ÃêO ,fÆcÒJ–ÏÜD–ŠX3­ˆ…e4oÆüÛÂ×O˜Î@TN®ëäÔkŸ(¯q–®ü.ïm¾ÅÔ~Åc>9Ù
öÄÍÄA•&õ’fm ¿ðÞýýK è<ˆø¤•ŽÊÌ0«ÑµðâÊj@Ú÷Õ¡Ú7¡(zlŠq¤Ëw=þìÇ×Ý0¸KÇ^]=ýàþâqe»
endstream
endobj
1 0 obj<</Parent 4 0 R/Contents 3 0 R/Type/Page/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/Font<</F1 2 0 R>>>>/MediaBox[0 0 300.98 495.38]>>
endobj
2 0 obj<</BaseFont/Times-Roman/Type/Font/Encoding/WinAnsiEncoding/Subtype/Type1>>
endobj
4 0 obj<</Type/Pages/Count 1/Kids[1 0 R]>>
endobj
5 0 obj<</Type/Catalog/Pages 4 0 R>>
endobj
6 0 obj<</Producer(iText 2.0.8 \(by lowagie.com\))/ModDate(D:20140225153804+05'30')/CreationDate(D:20140225153804+05'30')>>
endobj
xref
0 7
0000000000 65535 f 
0000000318 00000 n 
0000000480 00000 n 
0000000015 00000 n 
0000000569 00000 n 
0000000619 00000 n 
0000000663 00000 n 
trailer
<</Root 5 0 R/ID [<3edf7c900aab4e26d6ac2b1326544426><539a2d0a5c5a341b17d8331a3eab6622>]/Info 6 0 R/Size 7>>
startxref
794
%%EOF

这是使用强大的旧版 iText 生成的正常、有效的 PDF 文档。你会认出我的名字,它在 lowagie.com 上写着(我就是那个 Lowagie)。使用此文件不会有任何问题。

但是,如果您向下滚动,您会看到:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PDF&nbsp;Host</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="style.css" rel="stylesheet" type="text/css" />

<style type="text/css">
<!--
a:link {
    color: #999999;
    text-decoration: none;
}
a:visited {
    color: #CCCCCC;
    text-decoration: none;
}
a:hover {
    color: #99CCCC;
    text-decoration: none;
}
a:active {
    text-decoration: none;
}
.style1 {color: #FFFFFF}
-->
</style>
<script type="text/javascript">

  var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-24601794-1']);
      _gaq.push(['_trackPageview']);

        (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
              })();

              </script>
              </head>
<body bgcolor="#2d878f" background="bkg.jpg" style="background-repeat:repeat-x" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<p>&nbsp;</p>
<table width="725" height="423" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<tr>
    <td height="197" valign="top">
    <img src="images/pdfhost2_01.jpg" width="725" height="197" alt=""></td>
  </tr>
    <tr>
        <td height="53"><table width="725" height="53" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <th bgcolor="133841" scope="col"><a href="index.php" class="style1">Home</a> - <a href="index.php?Action=Upload" class="style1">Upload PDF&nbsp;Document</a></th>
          </tr>
        </table></td>
    </tr>
    <tr>
      <td valign="top"><table width="725" height="175" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <th height="59" background="tbk.jpg" scope="col"><div align="center"></div>
            <table width="680" height="306" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <th valign="top" scope="col">                  <p align="center"><br>
                </p>
<p align="left" class="style2">

                  Welcome to PDFHost.NET!<br /><br />

                  On this website you can upload PDF documents to send to your friends, family, and other people.<br />
                  The service on this website is completely free. We can provide this service through our advertisers.<br /><br />

                  To upload a PDF document, please click on the button below. You will be asked to fillin all the needed information to complete the upload.<br /><br />
                  <p align="center"><a href="index.php?Action=Upload"><img src="button.jpg" style="border-style: none"/></a> </p>

                                </p><br /><br />
    <script type="text/javascript"><!--
google_ad_client = "ca-pub-3986885209750256";
/* PDFHost.net */
google_ad_slot = "9986575127";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
    <br>
            </p></th>
          </tr>
        </table>

        <p align="left">&nbsp;</p></th>
      </tr>
    </table></td>
</tr>
<tr>
    <td>
        <img src="images/pdfhost2_04.jpg" width="725" height="10" alt="">   </td>
</tr>
</table>

<p>&nbsp;</p>
</body>
</html>

这是 HTML,不属于 PDF 文件。应该清楚的是,这个 HTML 不是由 iText 添加的。 Adobe Reader 将忽略 HTML 并正确显示 PDF,但在您尝试关闭 PDF 时会要求您保存 PDF。其他工具可能对 HTML 有问题。

如何解决这个问题?扔掉%%EOF 之后的所有内容,您将拥有一个有效的 PDF。我用 Adob​​e Preflight 对此进行了测试,我得到了一个绿色的复选标记(意思是:PDF 中没有语法错误)。

我的回答有可能不相关:HTML 似乎是由您用来分发 PDF 的服务添加的(PDFHost.NET,一家显然找到了一种相当肮脏的推广方式的公司本身)。既然如此,请使用不会污染“证据”的分发渠道;-)

我很确定问题与 iText 无关,因为您说该服务在发送使用 iText 生成的单个文件时有效,只有在您发送两个文件时才有效。这就提出了一个问题,当您发送两个文件时有什么不同:您使用哪种方法来合并两个文件?

最后:我看到 PDF 是使用 iText 2.0.8 创建的。如果您知道谁创建了这些 PDF,请让他或她升级到更新的版本。请参阅http://itextpdf.com/salesfaq(该版本不再受支持,如果继续使用,您可能会遇到其他更严重的问题)。

【讨论】:

  • 嗨 Bruno Lowagie,你是对的,html 不是由 iText 添加的,而是由 PDFHost.net 添加的。我尝试发送的文件在 %%EOF 之后不包含任何内容。但是docusign rest api仍然抛出http 400错误。我想知道docusign拒绝它的pdf有什么问题。当我尝试将两个标准pdf发送到docusign时,代码也可以正常工作。仅当我尝试发送我的代码正在生成的两个 pdf 时才会出现问题。因此,我确信问题不在代码中。顺便说一句,感谢人的帮助。
  • 在使用 Acrobat Preflight 时,单独的文件都给出了绿色复选标记,这意味着它们没有任何问题。 Docusign 应该接受它们并接受它们。如果Docusign 在组合时 不接受它们,那么在组合它们时你做错了。 这是由 组合的方式引起的它们或 Docusign 接受它们的方式。在前一种情况下,您应该解释如何组合文件;在后一种情况下,您应该联系 DocuSign(毕竟:您付钱给他们,您应该得到支持)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-08-04
  • 1970-01-01
  • 1970-01-01
  • 2012-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多