Reputation: 51
I am trying to send two pdfs within an envelope to docusign. The pdfs were generated using iText library. This problem occurs only while using pdf generated by iText. Other (downloaded from web) pdfs are working fine in my application with docusign so there's no issue in the java code. Also there's no problem in sending a single (iText generated) pdf within the envelope. Problem occurs only when sending multiple (iText generated) pdf documents. While using docusign REST api to send this pdf I am receiving a http 400 Bad Request error. Could anyone point out the problem in my pdf.
Here are the links to the pdf which I am trying to send.
http://www.pdfhost.net/index.php?Action=Download&File=c8eeab729a8299e08e643d99afa00672 http://www.pdfhost.net/index.php?Action=Download&File=c8e0d2b8dfa9c2b82d10cc0503995310
Thanks in advance.
----- EDIT -----
I tried these two documents after using 'Save As a new PDF' option in Adobe Reader and saving the documents. After this the two pdfs successfully got uploaded to docusign. Can somebody help me with the changes that Adobe Reader made to my documents that made it work with docusign. Also the size of the pdfs increased and fast web view property got set to YES after using 'Save as new pdf' option.
----- EDIT -----
Here's is my request content to docusign. This time using a simple text pdf generated by iText. This request is also throwing a 400 Bad request error.
--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":"[email protected]","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--
Upvotes: 1
Views: 879
Reputation: 77606
I have tested your PDFs and I have proof that the problem is not caused by iText, but by a bug introduced by the person who used iText to create the PDF or the service that provides the PDF. Please open the document in a plain text editor. You'll see this:
%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
This is a normal, valid PDF document generated with a mighty old version of iText. You'll recognize my name where it says by lowagie.com (I'm that Lowagie). You won't have any problems with this file.
However, if you scroll down, you'll see:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PDF 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> </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 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"> </p></th>
</tr>
</table></td>
</tr>
<tr>
<td>
<img src="images/pdfhost2_04.jpg" width="725" height="10" alt=""> </td>
</tr>
</table>
<p> </p>
</body>
</html>
This is HTML and this doesn't belong in a PDF file. It should be clear that this HTML isn't added by iText. Adobe Reader will ignore the HTML and show the PDF correctly, but it will ask you to save the PDF when you try closing it. Other tools may have a problem with the HTML.
How to solve this? Throw away everything after %%EOF
and you'll have a valid PDF. I've tested this with Adobe Preflight and I got a green check mark (meaning: there are no syntax errors in the PDF).
There is a chance that my answer isn't relevant: it appears that the HTML is added by the service you're using to distribute the PDFs (PDFHost.NET, a company that apparently has found a rather dirty way to promote itself). It that's the case, please use a distribution channel that doesn't taint the "evidence" ;-)
I'm pretty sure the problem isn't related to iText because you say the service works when sending a single file generated with iText, only when you send two. This raises the question what's different when you send two: which method to you use to combine both documents?
Finally: I see that the PDFs were created using iText 2.0.8. If you know who created those PDFs, please ask him or her to upgrade to a more recent version. See http://itextpdf.com/salesfaq (that version is no longer supported and you risk bumping into other, more serious problems if you continue using it).
Upvotes: 1