I am using Itext pdf java library to generate pdf document.
Need to add an image to pdf page after some text snippet. As per current design, the first text will be added to pdf and later on based on the PdfPageEventHelper images will be added.
Now the problem is text snippet can be of any length. So while adding the image I need to provide x and y coordinates. How can I calculate that based on the length of text snippet on that page so that text and image don't overlap?
Related
I am new in PDFBOX, and I am trying to move text from a coordinate into another coordinate. is it possible to move an existing text?
here is my pdf screenshot.
enter image description here
I want to move B.
I'm calling Fedex API to generate a shipping label. The API returns a byte array. I then write this byte array to a pdf using:
Files.write(Paths.get("xyz.pdf"), imgBytes); //imgBytes is the response I get from Fedex API
However, when I open the file, I see that the actual label occupies only about 2/3rd by width and 1/2 by height of the entire pdf because of which I'm having a lot of white space in the PDF.
Is it possible to somehow remove this white-space using PDFBox? Or is it possible to remove the white-space while saving the byte array to the pdf file?
Thanks.
I'm using PDFBox to extract the images out of a PDF. My code is based on the example provided by PDFBox, here.
However, some images are being extracted as a number of horizontal 'strips', i.e. a single image in the PDF is extracted as 5 (for example) images that need stitching back together to form the whole image.
Why is this happening, and how do I stop it happening so I can extract the full single image?
I need to delete a text in several PDF files, which is always at the same position. How to achieve this with iText?
I've tried to use the PdfStamper and draw a white filled rectangle over this. This was ok, but the text wasn't really deleted and each PDF Reader (Acrobta, Foxit, etc.) were able to mark the content (ctrl+a), copy and paste it.
I am writing a program that would validate PDF file. I am using iText java library to get content of a file, but I have some problems with parsing it. I need to get info about color space and DPI of each image. How can I get info about position and dimensions of image in PDF? I tried to browse each XObject of PDF but I stuck, I cannot find any information about width and height of file in PDF.
Are there any other libraries which can help me?
Thank You for all answers and tips.
The image object in the PDF file stores only the Width and the Height of the image in pixels. In order to know the position and size of the image on the page, in PDF points, you have to execute the page content stream, to create a virtual rendering. The image is painted on the page using the 'Do' operator and its position and size are given by the current transformation matrix that is in place when the 'Do' operator is executed.
The DPI for a specific drawing instance is computed as 72*imageSizeInPixels/imageSizeInPoints, imageSizeInPoints being computed as described above.