parent
7521d51206
commit
d474e03345
@ -0,0 +1,49 @@
|
||||
#ifndef PDFREADER_H
|
||||
#define PDFREADER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
// 解析 FlateDecode
|
||||
#include <zlib.h>
|
||||
// 解析 JPEG (DCTDecode)
|
||||
#include <jpeglib.h>
|
||||
|
||||
// PDF 解析类
|
||||
class PDFReader {
|
||||
public:
|
||||
PDFReader(const std::string& filepath);
|
||||
~PDFReader();
|
||||
|
||||
std::string parseHeader();
|
||||
|
||||
void parseXRefTable();
|
||||
|
||||
std::string extractText();
|
||||
|
||||
void listPDFObjects();
|
||||
|
||||
void extractImages(); // 解析 DCTDecode (JPEG) 图片
|
||||
|
||||
void parseFlateDecode(); // 解析压缩流数据
|
||||
|
||||
void parseTables(); // 解析表格
|
||||
|
||||
void renderPDF(); // 绘制 PDF 页面
|
||||
|
||||
private:
|
||||
std::ifstream file;
|
||||
|
||||
std::map<int, std::streampos> objectOffsets;
|
||||
|
||||
std::string readBytes(std::streampos position, size_t length);
|
||||
|
||||
void findObjects();
|
||||
|
||||
std::string parseStream(std::streampos start, size_t length);
|
||||
|
||||
};
|
||||
|
||||
#endif // PDFREADER_H
|
Loading…
Reference in new issue