The easiest way to do this is to create a new PDF file with the desired table in the right place, and then print it onto an existing PDF file. This can be done in code using (for example) the PdfStamper class, but there are also standalone tools like pdftk and many others. Do not think of it as βeditingβ a PDF file, think of it as adding something new on top of the original.
pdftk original.pdf stamp newtable.pdf output combined.pdf
In fact, the interesting and potentially difficult part was discussed in the @mkl source question - how do you determine the correct position of a new table. If you can come up with a geometric rule, then you are in good shape. If this involves any analysis of the source file, you should be aware that something like (seemingly) simple, since determining the number of rows in an existing table can sometimes be extremely difficult. Apparently, like the html <table> , which is similar in the content stream. An example of an actual PDF would be very helpful. A PDF image is not the same thing.
To give you some background information, parsing the layout of a PDF file is simple, as PDF readers do. Parsing PDF content is completely different and much more complicated. Just like an example, you can publish a PDF image from top to bottom, or you can draw headers and footers first, and then all the bold face elements followed by plain text. Just because two things are next to each other in a physical layout does not mean that they are next to each other in a file structure, object tree, or content stream. This is a vector graphic, not a text file or bitmap. PDF files are not intended for editing, unless the software they create provides information on how to edit the content. There are many things that seem like they should be easy, but once you understand how a PDF document is created, it makes sense that it is difficult. I am not talking about this to dissuade you, just so that you appreciate the scale of the task. If you can trace the original document from which this PDF file was created, I guarantee that you will have more success with less frustration.
James duvall
source share