How to move block of text in a PDF (using PDFBox)

孤人 提交于 2019-12-12 06:48:14

问题


I'm currently trying to generate PDF with PDFBox for some manual cover and I was wondering if it was possible to take a precise zone of text in my PDF and move it (to the left) depending on my manuel thickness (which will be determined by the number of pages my manual will have)

I manage to create my PDF just fine, but I did not find a way to get only a block of text.

Is it possible to do so with PDFBox?

Note : I tried to search on the web and on other questions, but none of them were useful.

Thanks


回答1:


Wrap saveGraphicsState() and restoreGraphicsState() around that block. Within that, use moveTextPositionByAmount() (after beginText() !) or setTextTranslation() or (more general) concatenate2CTM(1, 0, 0, 1, tx, ty) to move the position.




回答2:


Like i said in a comment, we decided to create a new PDF with the informations needed instead of trying to edit an existing one.

We tried to edit the PDF but in vein and when we decided to start from scratch, it was way more easier to do so.

Thanks to the people who tried to help me !



来源:https://stackoverflow.com/questions/25248981/how-to-move-block-of-text-in-a-pdf-using-pdfbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!