pdf to text python 3

#include <iostream>
#include <fstream>
#include <string>

int main() {
    std::ifstream pdfFile("example.pdf", std::ios::binary);
    std::ofstream textFile("output.txt");

    if (pdfFile.is_open() && textFile.is_open()) {
        std::string line;
        while (std::getline(pdfFile, line)) {
            textFile << line << std::endl;
        }

        std::cout << "PDF successfully converted to text." << std::endl;

        pdfFile.close();
        textFile.close();
    } else {
        std::cerr << "Error opening files." << std::endl;
    }

    return 0;
}