Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to decode the xref stream,i try use the zlib to decode the stream
such as(PDF1.6):
XML
endobj
66 0 obj<</ID[<BEC815FAE920FA49BC95137CB963B597><E5BAAF8902465FB2FA94F1593AB60200>]/Info 30 0 R/Prev 116/Root 32 0 R/Size 67/Type/XRef/W[1 3 1]/Index[30 1 51 1 64 3]/DecodeParms<</Columns 5/Predictor 12>>/Filter/FlateDecode/Length 32>>stream
x赾bb`p`
endstream
endobj

my code:(buffer(char *) save the string of obj)
<pre lang="c++/c">
		int m_start=FindString(buffer,PCSTREM,buffersize);
		int m_end=FindString(buffer,PCENDSTREAM,buffersize);
		if(m_start&&m_end&&(m_end>m_start))
		{
			m_start += 6;
			if(buffer[m_start]==0x0d&&buffer[m_start+1]==0x0a)
				m_start+=2;
			else if(buffer[m_start]=0x0a)
				m_start++;
			if(buffer[m_end-2]==0x0d&&buffer[m_end-1]==0x0a)
				m_end-=2;
			else if(buffer[m_start-1]=0x0a)
				m_end--;
			size_t outsize = (m_end - m_start)*10;
			char* output = new char [outsize]; 
			ZeroMemory(output, outsize);
			z_stream zstrm;
			ZeroMemory(&zstrm, sizeof(zstrm));

			zstrm.avail_in = m_end-m_start+1;
			zstrm.avail_out = outsize;
			zstrm.next_in = (Bytef*)(buffer + m_start);
			zstrm.next_out = (Bytef*)output;

			int rsti = inflateInit(&zstrm);
			if (rsti == Z_OK)
			{
				int rst2 = inflate (&zstrm, Z_FINISH);
				if (rst2 >= 0)
				{
					size_t totout = zstrm.total_out;
					printf("decode:%d \n",totout);
				}
			}

but i can't do it very well,i find messy code in the output,how can help me!
Posted
Updated 22-Mar-12 22:39pm
v6

1 solution

some one can help me?
i want to decode my xref table,help ,help
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900