update
This commit is contained in:
parent
5bf2952c03
commit
43ece1be95
@ -136,11 +136,12 @@ class PdfResultActivity : BaseActivity() {
|
|||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
isProcessing = true
|
isProcessing = true
|
||||||
binding.processingLayout.visibility = View.VISIBLE
|
binding.processingLayout.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
if (source == PdfPickerSource.SPLIT) {
|
||||||
binding.progressBar.isIndeterminate = false
|
binding.progressBar.isIndeterminate = false
|
||||||
binding.progressBar.progress = 0
|
binding.progressBar.progress = 0
|
||||||
binding.progressBar.max = 100
|
binding.progressBar.max = 100
|
||||||
}
|
|
||||||
if (source == PdfPickerSource.SPLIT) {
|
|
||||||
val totalPages = selectedList.sumOf { it.pages.count { it.isSelected } }
|
val totalPages = selectedList.sumOf { it.pages.count { it.isSelected } }
|
||||||
var processedPages = 0
|
var processedPages = 0
|
||||||
for (item in selectedList) {
|
for (item in selectedList) {
|
||||||
@ -174,6 +175,9 @@ class PdfResultActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (source == PdfPickerSource.MERGE) {
|
} else if (source == PdfPickerSource.MERGE) {
|
||||||
|
binding.progressBar.isIndeterminate = false
|
||||||
|
binding.progressBar.progress = 0
|
||||||
|
binding.progressBar.max = 100
|
||||||
if (inputFile.isNotEmpty()) {
|
if (inputFile.isNotEmpty()) {
|
||||||
val inputFiles: List<File> = inputFile.map { path -> File(path) }
|
val inputFiles: List<File> = inputFile.map { path -> File(path) }
|
||||||
val outputDir = File(
|
val outputDir = File(
|
||||||
@ -207,7 +211,6 @@ class PdfResultActivity : BaseActivity() {
|
|||||||
PdfSecurityUtils.setPasswordToPdfWithProgress(
|
PdfSecurityUtils.setPasswordToPdfWithProgress(
|
||||||
filepath, password, password
|
filepath, password, password
|
||||||
) { progress ->
|
) { progress ->
|
||||||
binding.progressBar.progress = progress
|
|
||||||
binding.progressTv.text = "$progress"
|
binding.progressTv.text = "$progress"
|
||||||
}.let { it ->
|
}.let { it ->
|
||||||
if (it) {
|
if (it) {
|
||||||
|
|||||||
@ -115,7 +115,7 @@ object PdfUtils {
|
|||||||
if (!outputDir.exists()) outputDir.mkdirs()
|
if (!outputDir.exists()) outputDir.mkdirs()
|
||||||
val outputFile = File(outputDir, outputFileName)
|
val outputFile = File(outputDir, outputFileName)
|
||||||
try {
|
try {
|
||||||
PDDocument.load(inputFile).use { document ->
|
PDDocument.load(inputFile, MemoryUsageSetting.setupTempFileOnly()).use { document ->
|
||||||
PDDocument().use { newDocument ->
|
PDDocument().use { newDocument ->
|
||||||
// 按页索引排序,保证顺序正确
|
// 按页索引排序,保证顺序正确
|
||||||
val sortedPages = selectedPages.sortedBy { it.pageIndex }
|
val sortedPages = selectedPages.sortedBy { it.pageIndex }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user