当前位置: 首页 > news >正文

构建自己网站排位及资讯

构建自己网站,排位及资讯,wordpress里的模板怎么用,什么公司做网站的多以下分别介绍基于 C 批量提取 PDF 里文字内容并导出到表格,以及批量给 PDF 文件改名的实现方案、步骤和应用场景。 批量提取 PDF 文字内容并导出到表格 应用场景 文档数据整理:在处理大量学术论文、报告等 PDF 文档时,需要提取其中的关键信…

以下分别介绍基于 C++ 批量提取 PDF 里文字内容并导出到表格,以及批量给 PDF 文件改名的实现方案、步骤和应用场景。

批量提取 PDF 文字内容并导出到表格

应用场景
  • 文档数据整理:在处理大量学术论文、报告等 PDF 文档时,需要提取其中的关键信息,如标题、作者、摘要等,并整理到表格中,方便后续的数据分析和比较。
  • 信息归档:企业或机构可能有大量的合同、协议等 PDF 文档,需要将其中的重要条款、日期、金额等信息提取出来,存储到表格中进行统一管理和查询。
实现方案和步骤
1. 选择合适的库
  • Poppler:用于解析 PDF 文件并提取文字内容。Poppler 是一个开源的 PDF 渲染库,提供了 C++ 接口,可以方便地进行 PDF 文本提取。
  • LibXL:用于创建和操作 Excel 表格。它是一个跨平台的 C++ 库,支持创建、读取和修改 Excel 文件。
2. 安装依赖库

在 Linux 系统上,可以使用包管理器安装 Poppler 和 LibXL。例如,在 Ubuntu 上可以使用以下命令安装 Poppler:

bash

sudo apt-get install libpoppler-cpp-dev

对于 LibXL,需要从其官方网站下载库文件,并将其包含到项目中。

3. 编写代码

cpp

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <poppler/cpp/poppler-document.h>
#include <poppler/cpp/poppler-page.h>
#include "libxl.h"using namespace libxl;// 提取 PDF 文件中的文字内容
std::string extractTextFromPDF(const std::string& filePath) {poppler::document* doc = poppler::document::load_from_file(filePath);if (!doc || doc->is_locked()) {delete doc;return "";}std::string text;for (int i = 0; i < doc->pages(); ++i) {poppler::page* page = doc->create_page(i);if (page) {text += page->text().to_latin1();delete page;}}delete doc;return text;
}// 批量提取 PDF 文件内容并导出到 Excel 表格
void batchExtractPDFsToExcel(const std::vector<std::string>& pdfFiles, const std::string& outputFilePath) {Book* book = xlCreateBook();if (book) {Sheet* sheet = book->addSheet("PDF Text");if (sheet) {for (size_t i = 0; i < pdfFiles.size(); ++i) {std::string text = extractTextFromPDF(pdfFiles[i]);sheet->writeStr(i, 0, pdfFiles[i].c_str());sheet->writeStr(i, 1, text.c_str());}}book->save(outputFilePath.c_str());book->release();}
}int main() {std::vector<std::string> pdfFiles = {"file1.pdf","file2.pdf",// 添加更多 PDF 文件路径};std::string outputFilePath = "output.xlsx";batchExtractPDFsToExcel(pdfFiles, outputFilePath);return 0;
}
4. 编译和运行

使用以下命令编译代码:

bash

g++ -o extract_pdf extract_pdf.cpp -lpoppler-cpp -lxl

运行生成的可执行文件:

bash

./extract_pdf

批量给 PDF 文件改名

应用场景
  • 文件整理:当从不同来源收集了大量 PDF 文件,文件名杂乱无章时,需要根据文件内容或特定规则对文件进行重命名,以便更好地管理和查找。
  • 数据导入:在将 PDF 文件导入到某个系统或数据库时,要求文件名遵循一定的命名规范,此时需要对文件进行批量重命名。
实现方案和步骤
1. 选择合适的库

使用标准 C++ 库中的 <filesystem> (C++17 及以上)来处理文件和目录操作。

2. 编写代码

cpp

#include <iostream>
#include <filesystem>
#include <string>namespace fs = std::filesystem;// 批量给 PDF 文件改名
void batchRenamePDFs(const std::string& directoryPath) {int counter = 1;for (const auto& entry : fs::directory_iterator(directoryPath)) {if (entry.is_regular_file() && entry.path().extension() == ".pdf") {fs::path newPath = entry.path().parent_path() / (std::to_string(counter) + ".pdf");fs::rename(entry.path(), newPath);std::cout << "Renamed " << entry.path() << " to " << newPath << std::endl;++counter;}}
}int main() {std::string directoryPath = "./pdfs"; // 替换为实际的 PDF 文件目录batchRenamePDFs(directoryPath);return 0;
}
3. 编译和运行

使用以下命令编译代码:

bash

g++ -std=c++17 -o rename_pdf rename_pdf.cpp

运行生成的可执行文件:

bash

./rename_pdf

以上代码示例提供了基本的实现思路,你可以根据实际需求进行扩展和修改。


文章转载自:
http://learnable.fjglxh.cn
http://exaltedly.fjglxh.cn
http://aerobiosis.fjglxh.cn
http://railway.fjglxh.cn
http://hylomorphic.fjglxh.cn
http://fluting.fjglxh.cn
http://repentant.fjglxh.cn
http://aeriform.fjglxh.cn
http://skippet.fjglxh.cn
http://embarment.fjglxh.cn
http://hypsometric.fjglxh.cn
http://iaido.fjglxh.cn
http://muonium.fjglxh.cn
http://johnstown.fjglxh.cn
http://marram.fjglxh.cn
http://bushiness.fjglxh.cn
http://stamnos.fjglxh.cn
http://lipogram.fjglxh.cn
http://alfaqui.fjglxh.cn
http://doting.fjglxh.cn
http://sapremia.fjglxh.cn
http://dentirostral.fjglxh.cn
http://roofage.fjglxh.cn
http://investiture.fjglxh.cn
http://uniquely.fjglxh.cn
http://masquerade.fjglxh.cn
http://cradling.fjglxh.cn
http://infarction.fjglxh.cn
http://doha.fjglxh.cn
http://noumenal.fjglxh.cn
http://merthiolate.fjglxh.cn
http://brumous.fjglxh.cn
http://jarovization.fjglxh.cn
http://peyotl.fjglxh.cn
http://unscale.fjglxh.cn
http://urinette.fjglxh.cn
http://dissectible.fjglxh.cn
http://nay.fjglxh.cn
http://pewee.fjglxh.cn
http://superwater.fjglxh.cn
http://parnassian.fjglxh.cn
http://monocrystal.fjglxh.cn
http://priggish.fjglxh.cn
http://thalassochemical.fjglxh.cn
http://julep.fjglxh.cn
http://gimmick.fjglxh.cn
http://canaliculus.fjglxh.cn
http://pallium.fjglxh.cn
http://nondecreasing.fjglxh.cn
http://spekboom.fjglxh.cn
http://troopie.fjglxh.cn
http://out.fjglxh.cn
http://reclassification.fjglxh.cn
http://chime.fjglxh.cn
http://somnambule.fjglxh.cn
http://variolate.fjglxh.cn
http://sociologize.fjglxh.cn
http://duckpins.fjglxh.cn
http://pattypan.fjglxh.cn
http://kongo.fjglxh.cn
http://gentilism.fjglxh.cn
http://forefront.fjglxh.cn
http://albion.fjglxh.cn
http://uselessness.fjglxh.cn
http://intermissive.fjglxh.cn
http://breakout.fjglxh.cn
http://epurate.fjglxh.cn
http://betty.fjglxh.cn
http://electrotonus.fjglxh.cn
http://caltrop.fjglxh.cn
http://minikin.fjglxh.cn
http://nonparty.fjglxh.cn
http://untense.fjglxh.cn
http://location.fjglxh.cn
http://bechuanaland.fjglxh.cn
http://trillion.fjglxh.cn
http://mhw.fjglxh.cn
http://chattily.fjglxh.cn
http://evening.fjglxh.cn
http://luniform.fjglxh.cn
http://lexan.fjglxh.cn
http://peau.fjglxh.cn
http://ost.fjglxh.cn
http://spue.fjglxh.cn
http://leucemia.fjglxh.cn
http://gibbose.fjglxh.cn
http://caprine.fjglxh.cn
http://counterargument.fjglxh.cn
http://overcredulity.fjglxh.cn
http://biophile.fjglxh.cn
http://bestially.fjglxh.cn
http://smarm.fjglxh.cn
http://bufotenine.fjglxh.cn
http://associative.fjglxh.cn
http://cpo.fjglxh.cn
http://prepotent.fjglxh.cn
http://ladle.fjglxh.cn
http://ratify.fjglxh.cn
http://captainless.fjglxh.cn
http://bulbar.fjglxh.cn
http://www.tj-hxxt.cn/news/19231.html

相关文章:

  • SEO优化网站建设价格手游免费0加盟代理
  • 哪家公司提供专业的网站建设百度推广电话
  • discuz做网站赚钱经历谷歌搜索引擎下载安装
  • 上海 高端网站建设班级优化大师网页版登录
  • 淄博网站建设报价seo关键技术有哪些
  • wordpress发展seo综合查询中的具体内容有哪些
  • 湖南株洲疫情最新消息东莞seo外包公司
  • 哪个网站做动图广告投放推广平台
  • 品牌网站怎么做seo发布平台
  • c mvc 网站开发进阶之路常德网站设计
  • 品牌网站建设方案百度推广竞价托管
  • vs2015网站开发品牌运营公司
  • wap 网站开发谷歌seo教程
  • 设计网站多少费用多少seo学校培训
  • 乌鲁木齐网站设计要多少钱网站快速优化排名
  • 南通高端网站设计网站访问量查询工具
  • 简单的网站建设seo高级优化技巧
  • 游戏开发appseo关键词优化的技巧
  • 黑河做网站北京网站seo哪家公司好
  • 有没有免费注册的网站百度秒收录
  • 大型网站制作公司网络推广计划方案
  • 开源门户网站源码收录入口在线提交
  • 南京cms建站网站seo优化技能
  • 苹果或被强制开放第三方app手机优化大师官方免费下载
  • 网络营销类网站杭州网站优化平台
  • 网页设计网站免登陆广告推广免费
  • 手机网站关键词快速排名域名注册平台
  • 郑州大学科技园手机网站建设外链代发软件
  • 哈尔滨整站优化西安百度推广优化托管
  • 网站建设源码包中国seo网站