Search code examples
javapdfsvgcreationpdfbox

Create a pdf with text at given coordinates (PDFBox?)


My Situation:

  • I'm programming in java
  • Using a library from a person from my university I'm able to read pdfs and create a XML document out of it
  • This XML document contains additional informations e.g. the coordinates of the text in the original document

My Problem

  • I would like to create the read PDF again with the content set at its original coordinates (Again: I have the coordinates)

My Question:

-> Do you know a way to create a pdf and set the text of the pdf at given coordinates? <-

I'm doing a lot of research these days about, but maybe I tried the wrong google search terms since I cant find much helpful results. So i thought I might be able to ask here, in the forum where I found the most help so far in my young "programmers life" :)

Most of the results I get, even here, are about people trying to get the coordinates, but I already have them.

I heard during a discussion that PDFBox might be able to do this, but I'm also happy to work with any other framework or library that is capable for my problem.

Thanks for every help and thought you're sharing with me.


Solution

  • Thanks a lot for your comments. In the end I've decided for iText, which allowed me to do all my tasks (placing text at absolute coordinates, give it a background color by certain criterias) in a quite easy and efficient way.

    If someone here is searching for inspiration and has a similar task, check my related post here on stackoverflow for some code snippets How can I add a background color to my (pdf-) text using iText to create it with Java