[Idea] Re-shuffling pdf pages randomly [minor idea, minor use case] #404
Closed
rubyFeedback
started this conversation in
Ideas
Replies: 1 comment
-
|
At the moment I don't think that shuffling pages around is a feature that will make it into the HexaPDF binary. However, I think the easiest way to do this would be to use the require 'hexapdf'
doc = HexaPDF::Document.open(ARGV[0])
page_count = doc.pages.count
page_count.times do |i|
doc.pages.move(i, rand(page_count))
end
doc.write("shuffled.pdf", optimize: true)As for "StackOverflow for HexaPDF": I think that Github discussion together with the issue tracker should be fine for now as Github allows searching inside a repo. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The following is an idea.
Recently on StackOverflow, I was trying to find out how to re-arrange the evince instances
I have where each evince instance holds one .pdf file. I am reading 10 different .pdf files and
thus I have 10 instances of evince open; this is not great. I'd wish evince would have tabs;
anyway, as I was trying to find out how to re-arrange windows on IceWM, to designate my
preferred reading oder of those .pdf files, I stumbled upon a StackOverflow search result.
This discussion on StackOverflow had "how to re-shuffle pages in a .pdf file and create a
new file". Their solution was to use pdftk and a few more applications (one involving
python).
I thought how would I solve this in hexapdf. + ruby Well, I'd probably extract each individual
.pdf page, in a working directory. If the .pdf file has 100 pages, then I'd have 100
individual .pdf files. Then I simply re-arrange from that list and use ruby's random
choice picker to simply merge them together. There are probably simpler alternatives
to this. Best would be for hexapdf to have --random or --randomize or something
like that. Though this is probably only rarely used or needed.
But this also got me thinking ... what if we could have something like StackOverflow
for hexapdf? We have the issue tracker; and the discussions here. This is fine. We
also have the webpage which has useful examples. I am thinking a bit more
of something between a wiki and a FAQ, where people could contribute knowledge,
a bit like StackOverflow, but so that it also is not lost. I am not sure how to best
enable this, so it is more a loose idea here. The basic ideas would be to:
a) bundle knowledge about hexapdf etc... in the repository or associated with it, but
b) without burdening the maintainer
I guess for the time being the discussions here should be fine. But people probably
rarely read old discussions and then information may be lost, which is why a FAQ
of "applied usage" would be better. But a FAQ is usually maintained by the author(s)
of the project, which adds burden to them, so this is not ideal either. Something a
bit like a mixture of FAQ and Wiki. Not sure if github offers anything like that; the
issue trackers and discussions are fine, the wiki on github in general is not that
great; I've seen that with jruby's wiki, where many links are ancient or don't even
work anymore.
Anyway, just a loose idea. Perhaps this becomes more useful at a later point in time.
Beta Was this translation helpful? Give feedback.
All reactions