frankz61 2020-12-04 16:06 采纳率: 57.1%
浏览 15

如何找到一个增量pdf文件的多个修订版本

大佬们,想问一下。如何在增量pdf中判断某一个修订版在某次增量过程中是否在签章后修改了。因为看到很多pdf软件在盖章的时候并不会显示当前文档在签章后被修改,但是在删除印章后会显示在签章后被修改,不知道这个逻辑是怎么判断的。如果只是简单的根据byterange去判断只能判断签名值和当前最后一个签章的修订版之后有没有增加。多个签章和多个修订版的逻辑就没办法判断了。

  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-07-24 20:38
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    要解决这个问题,我们可以使用C++中的std::ifstream来读取PDF文件并解析它。以下是一个示例程序,展示了如何查找某个特定修订版本在指定时间戳后的更改:

    #include <iostream>
    #include <fstream>
    #include <sstream>
    
    using namespace std;
    
    // Define a class to represent PDF content
    class PdfContent {
    public:
        string text;
        int pageNumber;
    };
    
    // Function to parse the PDF file and find the specific revision version's changes
    void findChanges(PdfContent& content, const string& timestamp) {
        // Open the PDF file
        ifstream pdfFile("path_to_your_pdf_file.pdf");
        if (!pdfFile.is_open()) {
            cerr << "Error opening PDF file." << endl;
            return;
        }
    
        // Read the PDF file line by line
        string line;
        while (getline(pdfFile, line)) {
            // Parse each line as a PDF page
            stringstream ss(line);
            PdfContent page;
            getline(ss, page.text, '\n');
            page.pageNumber = ss.tellg();
            
            // Check if the current page is the one we're looking for
            if (page.text.find(timestamp) != string::npos) {
                // Print out all changes in this page
                cout << "Changes found on page " << page.pageNumber << ":" << endl;
                for (int i = 0; i <= page.text.length(); ++i) {
                    char c = page.text[i];
                    if (c == '-' || c == '+') {
                        cout << "Change: '" << c << "' at position " << i + 1 << endl;
                    }
                }
            }
        }
    }
    
    int main() {
        // Replace 'timestamp' with the actual timestamp you want to search for
        findChanges(content, "2023-04-05T12:34:56Z");
    
        return 0;
    }
    

    这个程序首先打开PDF文件,并逐行读取。然后,对于每行,它尝试找出包含给定时间戳的内容。如果找到了,它就会打印出所有与该内容相关的更改。

    注意:这只是一个基本示例,实际操作时可能需要处理更复杂的情况,例如处理不同类型的修订版本(例如,文本修订、图像修订等),或者处理不同的格式或编码。

    评论

报告相同问题?