您能否分享一些有关您在合并文档时使用的不同类型分隔符的信息(非常感谢示例文档或图像)。如果您添加空白页作为分隔符,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 的开发布道者。