Not able to get actual document content by GET document API

Using Postman we are able to get the filling-history-accounts-document. However with the GET call we are able to receive the below data, how to extract actual PDF document out of it. Please help.
%PDF-1.1
%����
1 0 obj
<<
/Type /Catalog
/Pages 3 0 R

endobj
2 0 obj
<<
/CreationDate (D:20170915050336)
/ModDate (D:20170915050336)
/Producer (libtiff / tiff2pdf - 20150621)
/Creator (go-tiff2pdf)

endobj
3 0 obj
<<
/Type /Pages
/Kids [ 4 0 R ]
/Count 1

endobj
4 0 obj
<<
/Type /Page
/Parent 3 0 R
/MediaBox [0.0000 0.0000 595.0000 842.0000]
/Contents 5 0 R
/Resources <<
/XObject <<
/Im1 7 0 R >>
/ProcSet [ /ImageB ]

endobj
5 0 obj
<<
/Length 6 0 R

stream
q 595.0000 0.0000 0.0000 829.5879 0.0000 6.2061 cm /Im1 Do Q

endstream
endobj
6 0 obj
62
endobj
7 0 obj
<<
/Length 8 0 R
/Type /XObject
/Subtype /Image
/Name /Im1
/Width 1674
/Height 2334
/BitsPerComponent 1
/ColorSpace /DeviceGray
/Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 1674 /Rows 2334>>

stream
������������-��ZQ����-R��ZGX���k������� %����z@����J�ږ�Ca�(~�ۯ� �*,JZ�1#Z�j��,O�4��0�0�҆��@��֫.�":�ҊN�’X�ZR�N�&�Yki���e��U��,“�]$P�IiS�B+:�Z�����W��A{�T�I��W��ҝ�� ���g"�dhϑ��$��p�H)��ɰ�I�NȪ:�2x�72@S��.0�S�Na�OXw!�BTD���(r�˙p_�rs6��H’�J�BVG�’�PK��BЏ��V��e�PFߔ> �
t-B}���u��xM4�f�BE9)��ڪi���� �T�6���� ���w��7�ޚ�p�������O�V�v��_}AԐ�M�qtjN�l�rv��&�1�=t���/���c�7t�������[_��’K%�Y:ɡ��BM��]a�A5’�Ke�p�o��N�t�� �{� !�H��������w}������HR{]ӿK�]���Qz��"k��w�:M�}����w��_M���}w��������ǯ�����9a��va/��c�[�u�.�]5��Ϻ������R,w���T����Q�����������c�-�� �a
i�E����S����:���%��_�����-n�q.��������U�’�?�������V���^�q i/����ֱԐ�O^�?�ɾN���o~����ɟ��jC9;}�������ӓ=��M�)8{���Su���u�{e�w���w�NZ����c��8|���]�����o��ݏ�������x�������KI+����������~ =��������L�����{�]�}���Ķh��^�w������}/��u�In���K�V��W�-�o���+⭹�a�a�����v1�v��$a�Ph�AomM������Ew!�C��o����-��տ���!�hTuqQHu��i��������T�i������z��z�z��׆�[�O���
0Bf�DD8a4��ڦ�5�0�k
B-� ����`�a0B�T”""""""K��B��������DDDDDDDDD%������������O l�3�1�����—a:� ��:e:#�N�㑤N��:�.2C9��B@�8S��0.���! �d2 �
Bi궘A���0N M
S�M���gf)9���� �MV�Pi�����j��k���P��I��i޴���u ����_���!�u$�?�Gy:��9= ��<�S[�;�8v��O��%�;r}�;��>z������

Can you share your postman and get calls? Ideally in gists.

Controller:
$scope.getDocument=function(documenturl){
alert(documenturl);

        $http.get(documenturl+'/content', {
            headers: {'Authorization': 'Basic APIKey'}
          }).then(function success(response) { 


                  alert("Document Success");

In Postman we are using “https://document-api.companieshouse.gov.uk/document/xTbDT1Nkb_aC95-1iys2GsUwhQa1-Wnlh6C0PsH0Ft8/content

(I don’t use Postman) It’s not clear quite what you want. You say you receive data when you request the document, and you’ve quoted the first few lines of this. These seem to be the same as I receive when I request this file, and I can save the data and have a valid PDF. If that’s the case for you the issue doesn’t seem to be with Companies House.

You say “how to extract actual PDF document out of it”. The information you list appears to be the same PDF file as I can download. If you just save this into a file are you finding this is not a valid PDF?

Are you getting all the bytes of the file? The file size should be listed in the document meta information - seems to be 48546 bytes for this file and that’s what I receive (e.g. see https://document-api.companieshouse.gov.uk/document/xTbDT1Nkb_aC95-1iys2GsUwhQa1-Wnlh6C0PsH0Ft8 ).

For info, I tested this with curl to get the file (the -H specifies I want pdf mime type data, the -L tells curl to follow redirects):

curl -u{my api key}: -H “Accept: application/pdf” -L “https://document-api.companieshouse.gov.uk/document/xTbDT1Nkb_aC95-1iys2GsUwhQa1-Wnlh6C0PsH0Ft8/content” > test_doc.pdf

Background info: I get the filing history data from CH, the entry is:
{
“category”: “accounts”,

“description”: “accounts-with-accounts-type-total-exemption-small”,
“date”: “2012-03-27”,
“action_date”: “2011-01-31”,
“links”: {
“document_metadata”: “https://frontend-doc-api.companieshouse.gov.uk/document/xTbDT1Nkb_aC95-1iys2GsUwhQa1-Wnlh6C0PsH0Ft8”,
“self”: “/company/05342569/filing-history/MzA1NDgwNjk2NmFkaXF6a2N4”
},
“pages”: 6,
“barcode”: “X15KV3S3”,
“transaction_id”: “MzA1NDgwNjk2NmFkaXF6a2N4”
}

Chris