You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
924 B

#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