2021年4月6日星期二

empty pdf is created reading Pdf Stream with Filter FlateDecode /S 36 /Length 79 with appropriate page size

Hi i am trying read pdf stream from a server which and creating a file in java. strong text But unfortunately empty pdf is getting created having exact page size.

Let me know is this the way of reading or any alternative way is there? The response is having flatedeocde option. << /Filter /FlateDecode /S 36 /Length 79 >>

        InputStream is = new ByteArrayInputStream(decodedBytes);          try {              File file = new File("C:/Users/krish/Downloads/Sample/Test -123.pdf");              OutputStream outputStream = new FileOutputStream(file);              //BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));              byte[] buffer = new byte[1024];              int bytesRead = -1;              for (int length; (length = is.read(buffer)) != -1; ) {                  outputStream.write(buffer, 0, length);              }              is.close();              outputStream.close();               }          catch(FileNotFoundException ex ) {              ex.getStackTrace();          }  

And Below is the sample response of the Stream. Please let me know where it's going wrong. << /Filter /FlateDecode /S 36 /Length 79 >>

%PDF-1.7 %���� 3 0 obj << /Linearized 1 /L 166404 /H [ 891 156 ] /O 6 /E 165925 /N 1 /T 166226 >> endobj

xref 3 21 0000000015 00000 n 0000000814 00000 n 0000000891 00000 n 0000001047 00000 n 0000001402 00000 n 0000001435 00000 n 0000001472 00000 n 0000001505 00000 n 0000001651 00000 n 0000021043 00000 n 0000021242 00000 n 0000021559 00000 n 0000021915 00000 n 0000021996 00000 n 0000022213 00000 n 0000022468 00000 n 0000022525 00000 n 0000022582 00000 n 0000022768 00000 n 0000023028 00000 n 0000023178 00000 n trailer << /Info 2 0 R /Root 4 0 R /Size 24 /Prev 166218 /ID [<2e90e10fe549d36f1bdc6de1f72f7920><428bfd520f84280b30affdcb86a329a6>] >> startxref 0 %%EOF 4 0 obj << /Lang (en-US) /Pages 1 0 R /Type /Catalog /Version /1.7 >> endobj 5 0 obj << /Filter /FlateDecode /S 36 /Length 79 >> stream x�cb�f```j�c���Y@��t@�!

https://stackoverflow.com/questions/66970022/empty-pdf-is-created-reading-pdf-stream-with-filter-flatedecode-s-36-length-79 April 06, 2021 at 09:53PM

没有评论:

发表评论