Files
2026-10-12 16:49:14 +08:00

36 lines
896 B
C#
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Text;
using iTextSharp.text.pdf;
namespace PDFPatcher.Processor
{
sealed class RemoveThumbnailProcessor : IPageProcessor
{
int _processedItemCount;
public string Name => "删除缩略图";
public void BeginProcess(DocProcessorContext context) {
_processedItemCount = 0;
}
public bool EndProcess(PdfReader pdf) {
Tracker.TraceMessage(Tracker.Category.Notice, Name + "功能:");
Tracker.TraceMessage($"  删除了 {_processedItemCount} 幅缩略图。");
return false;
}
public int EstimateWorkload(PdfReader pdf) {
return pdf.NumberOfPages;
}
public bool Process(PageProcessorContext context) {
Tracker.IncrementProgress(1);
if (!context.Page.Contains(PdfName.THUMB)) {
return false;
}
context.Page.Remove(PdfName.THUMB);
_processedItemCount++;
return true;
}
}
}