Thank you very much, Jurassic Pork, for taking the time to reply.
Another research topic (one starts before another ends) has emerged for me.
I will consider your solution.
In the meantime, I did not sit idle and in my research;
I learned that the data in the pdf is encoded as FlateDecode. I'll do some more research, it sounds like it's solvable.
Thank you very much Jurassic Pork and winni, your suggestions made me have an idea about not reinventing the wheel.
I solved my problem with ghostscript.
By the way, ghostscript can easily split, merge and rotate pdf files.Respects.