如何在C ++中将pdf文件转换为excel?

如何在C ++中将pdf文件转换为excel?

问题描述:

我想将Pdf文件转换为Excel,它可以在C#中使用但我想用C ++。

任何人都可以帮我这个吗?

在此先感谢。



我尝试过的事情:



我已经完成了转换在c#中,但我的其他所有工作都是用c ++编写的,所以我也想在C ++中使用它。

I want to convert Pdf file into Excel, it is possible in C# but i want in C++.
Can anyone help me with this??
Thanks in advance.

What I have tried:

I have trued to convert in c# but my whole other work is in c++ so i want this also in C++..

这是一项非常复杂的任务。首先,PDF和Excel的文档性质不同,但由于放在PDF中的任何内容都可以放在Excel文件中,这是可行的。

首先下载这个开源PDF库。

然后,您可以打开PDF文件并访问其元素,如文本,字体,文本属性,图片等。

然后,最简单的方法是创建一个ASCII以.csv结尾的文件。这样的文件将在第一次使用时顺利导入Excel,然后您可以将其保存为本机Excel文件。更困难的部分是生成原生Excel文件。

您可以使用付费产品,或者像这一个免费。

这是一个使用以下方法创建第一个本机Excel文件的简单示例免费图书馆:

This is a very complex task. First, PDF and Excel are different in the nature of their documents but since anything placed in a PDF can be placed in an Excel file, that doable.
Start by downloading this open source PDF library.
You can then open a PDF file and access its elements such as text, font, text's attributes, pictures, etc.
Then, the easiest would be to create an ASCII file ending with .csv. Such file will be smoothly imported to Excel upon the first time it is used, then you can save it as a native Excel file. The more difficult part would be generating a native Excel file.
You can use this paid product, or a free one like this one.
Here is a simple example of creating your first native Excel file using the free library:
#include "xlsxwriter.h"
int main() {
    lxw_workbook  *workbook  = workbook_new("hello_world.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
    worksheet_write_string(worksheet, 0, 0, "Hello", NULL);
    worksheet_write_number(worksheet, 1, 0, 123, NULL);
    workbook_close(workbook);
    return 0;
}