Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
scheidan committed Jan 16, 2024
1 parent f9bd3fb commit 358163f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name = "PDFmerger"
uuid = "3beb2ed1-af7d-458f-b727-6e9beb3586c0"
authors = ["Andreas Scheidegger <[email protected]> and contributors"]
version = "0.3.0"
version = "0.3.1"

[deps]
Poppler_jll = "9c32591e-4766-534b-9725-b71a8799265b"

[compat]
julia = "1.6"
Poppler_jll = "^21.9"
Poppler_jll = "23"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
29 changes: 11 additions & 18 deletions src/PDFmerger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,25 @@ function merge_pdfs(files::Vector{T}, destination::AbstractString="merged.pdf";
if k == 1
outfile_tmp2 = "_temp_destination_$k"

pdfunite() do unite
run(`$unite $files_part $outfile_tmp2`)
end
run(`$(pdfunite()) $files_part $outfile_tmp2`)

else
outfile_tmp1 = "_temp_destination_$(k-1)"
outfile_tmp2 = "_temp_destination_$k"

pdfunite() do unite
run(`$unite $outfile_tmp1 $files_part $outfile_tmp2`)
end
run(`$(pdfunite()) $outfile_tmp1 $files_part $outfile_tmp2`)

end
k += 1
end

# rename last file
Filesystem.mv("_temp_destination_$(k-1)", destination, force=true)
Filesystem.mv("_temp_destination_$(k-1)", destination, force=true)

# remove temp files
Filesystem.rm(destination * "_x_", force=true)
Filesystem.rm.("_temp_destination_$(i)" for i in 1:(k-2))
if cleanup
# remove temp files
Filesystem.rm(destination * "_x_", force=true)
Filesystem.rm.("_temp_destination_$(i)" for i in 1:(k-2))
if cleanup
Filesystem.rm.(files, force=true)
end

Expand Down Expand Up @@ -112,10 +110,7 @@ end
Count pages numbers
"""
function n_pages(file)

str = pdfinfo() do info
read(`$info $file`, String)
end
str = read(`$(pdfinfo()) $file`, String)

m = match(r"Pages:\s+(?<npages>\d+)", str)
isnothing(m) && error("Could not extract number of pages from:\n\n $str")
Expand All @@ -142,9 +137,7 @@ function split_pdf(file::AbstractString; cleanup=false)
n = n_pages(file) |> ndigits
numberformat = n > 1 ? "%0$(n)d" : "%d"

pdfseparate() do seperate
run(`$seperate $file $(file_no_ending)_$numberformat.pdf`)
end
run(`$(pdfseparate()) $file $(file_no_ending)_$numberformat.pdf`)

if cleanup
Filesystem.rm(file, force=true)
Expand Down

0 comments on commit 358163f

Please sign in to comment.