1

我们正在使用用于 .Net 的 Aspose 工具进行 PDF 操作。我们有 1000 多个 pdf 文档需要合并然后再次拆分它们。合并过程将在合并时在两个 pdf 文档之间添加分隔页。这样拆分过程就会知道在哪里拆分文档。

这 1000 个文档由 3 种不同类型组成。所以我需要创建 3 个不同的分隔符(每种类型一个)。合并过程将根据文档类型在合并时添加适当的分隔符。

我知道如何使用 Aspose 合并和拆分 PDF 文档。我的问题是,如何创建和检测此分隔页?

我正在考虑的一个选项是创建一个带有特定条形码的 PDF 页面,并且拆分过程将读取条形码。(使用 Aspose Barcode ) 但这似乎是一个耗时的过程,因为拆分过程必须读取每一页,检查是否有条形码,如果为真,然后提取数据以检查类型。

还有其他更好的方法吗?

4

1 回答 1

0

您能否分享一些有关您在合并文档时使用的不同类型分隔符的信息(非常感谢示例文档或图像)。如果您添加空白页作为分隔符,Aspose.Pdf for .NET 提供了确定 PDF 文件中空白页的功能。但是仍然在使用这种方法时,您需要遍历所有页面并识别空白页面。或者,您还可以跟踪添加分隔符的索引以及何时需要拆分,使用相同的信息。

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

// Instantiate a memoryStream object to hold the extracted text from Document
MemoryStream ms = new MemoryStream();
// Instantiate PdfExtractor object
PdfExtractor extractor = new PdfExtractor();

// Bind the input PDF document to extractor
extractor.BindPdf(dataDir + "FilledForm.pdf");
// Extract text from the input PDF document
extractor.ExtractText();

bool containsText = false;
bool containsImage = false;
// Save the extracted text to a text file
extractor.GetText(ms);
// Check if the MemoryStream length is greater than or equal to 1
if (ms.Length >= 1)
containsText = true;

// Extract images from the input PDF document
extractor.ExtractImage();

// Calling HasNextImage method in while loop. When images will finish, loop will exit
if (extractor.HasNextImage())
containsImage = true;

// Now find out whether this PDF is text only or image only
if (containsText == true && containsImage == false)
Console.WriteLine("PDF contains text only");
else if (containsText == false && containsImage == true)
Console.WriteLine("PDF contains image only");
else if (containsText == true && containsImage == true)
Console.WriteLine("PDF contains both text and image");
else if (containsText == false && containsImage == false)
Console.WriteLine("PDF contains neither text or nor image");

我的名字是 Nayyer,我是 Aspose 的开发布道者。

于 2017-03-28T15:26:46.603 回答