如何使用c ++/c解码pdf的交叉引用流? [英] how to decode the Cross—Reference Streams of pdf using c++/c?

查看:177
本文介绍了如何使用c ++/c解码pdf的交叉引用流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想解码外部参照流,我尝试使用zlib解码流
例如(PDF1.6):

I want to decode the xref stream,i try use the zlib to decode the stream
such as(PDF1.6):

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


我的代码:(buffer(char *)保存obj的字符串)


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!

推荐答案

有人可以帮助我吗?
我想解码我的外部参照表help,help
some one can help me?
i want to decode my xref table,help ,help


这篇关于如何使用c ++/c解码pdf的交叉引用流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆