This commit is contained in:
ocean 2025-10-10 19:04:37 +08:00
parent 5bf2952c03
commit 43ece1be95
2 changed files with 7 additions and 4 deletions

View File

@ -136,11 +136,12 @@ class PdfResultActivity : BaseActivity() {
withContext(Dispatchers.Main) {
isProcessing = true
binding.processingLayout.visibility = View.VISIBLE
}
if (source == PdfPickerSource.SPLIT) {
binding.progressBar.isIndeterminate = false
binding.progressBar.progress = 0
binding.progressBar.max = 100
}
if (source == PdfPickerSource.SPLIT) {
val totalPages = selectedList.sumOf { it.pages.count { it.isSelected } }
var processedPages = 0
for (item in selectedList) {
@ -174,6 +175,9 @@ class PdfResultActivity : BaseActivity() {
}
}
} else if (source == PdfPickerSource.MERGE) {
binding.progressBar.isIndeterminate = false
binding.progressBar.progress = 0
binding.progressBar.max = 100
if (inputFile.isNotEmpty()) {
val inputFiles: List<File> = inputFile.map { path -> File(path) }
val outputDir = File(
@ -207,7 +211,6 @@ class PdfResultActivity : BaseActivity() {
PdfSecurityUtils.setPasswordToPdfWithProgress(
filepath, password, password
) { progress ->
binding.progressBar.progress = progress
binding.progressTv.text = "$progress"
}.let { it ->
if (it) {

View File

@ -115,7 +115,7 @@ object PdfUtils {
if (!outputDir.exists()) outputDir.mkdirs()
val outputFile = File(outputDir, outputFileName)
try {
PDDocument.load(inputFile).use { document ->
PDDocument.load(inputFile, MemoryUsageSetting.setupTempFileOnly()).use { document ->
PDDocument().use { newDocument ->
// 按页索引排序,保证顺序正确
val sortedPages = selectedPages.sortedBy { it.pageIndex }