torakiki / pdfsam

PDFsam, a desktop application to split, merge, mix, rotate PDF files and extract pages
https://pdfsam.org
GNU Affero General Public License v3.0
3.43k stars 343 forks source link

[Feature request] Re-ordering pages from a booklet PDF #111

Open maxiride opened 9 years ago

maxiride commented 9 years ago

I'd like to suggest a new feature which reorder the pages from a scanned booklet. A booklet (as the name suggest) comes in set of pages folded in the middle and inserted inside one in another. booklet

When unfolding a booklet we obtain separate sheets which doesn't contain the pages in the correct reading order. Assuming a 2 sheets booklet (8 pages) the first sheet will contain the pages (front\back of the sheet) 1-8, 2-7; the second sheet will have page 3-6,4-5 as shown: unfolded

Saying that we can already split the pages from each sheet we can obtain a PDF containing the pages in this order: 8,1,2,7,6,3,4,5. pdfsam already has a manual reordering tool which theoretically could be used to solve this issue, but I'd like to suggest an auto-sorting feature for the cases where the pages are many more than just 8 to obtain a PDF with the pages in the correct reading order. sorted

An user on this forum already made a little algorithm to solve this issue, but at least for me it isn't straightforward, having this little addition to pdfsam could make it a "point and click" solution for noobs :smile:

Edit: to avoid reading all the thread here is the code he made (thought to be run in excel as I understood)

Sub Macro1()
' by rumeyj

Dim i As Integer, lastPg As Integer
Dim extN As String, othN As String

lastPg = Cells(2, 2).Value 'this cell B2 is where the total number of pages is input

If lastPg Mod 4 > 0 Then lastPg = lastPg + 4 - (lastPg Mod 4)

Range("a5:a100").Clear
Range("A4").Select

For i = 1 To lastPg / 2
    extN = Format(i, "00")
    othN = Format(lastPg - i + 1, "00")

If i Mod 2 Then 'i is odd
    'Debug.Print i; "i is odd"
    PonNextLine ("rename e" & extN & ".jpg " & othN & ".jpg")
    PonNextLine ("rename o" & extN & ".jpg " & extN & ".jpg")
Else
    PonNextLine ("rename e" & extN & ".jpg " & extN & ".jpg")
    PonNextLine ("rename o" & extN & ".jpg " & othN & ".jpg")
End If
Next i
End Sub

Function PonNextLine(ln As String)
'print on next line
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = ln
End Function
maxiride commented 3 years ago

Been out of the loop for a while, is this feature rejected?