Position of PDF element using itext7 - itext

I am trying to get the position of Paragraph in pdf file.
Right now I get it at pdf generation time, by getting the current position before/after adding the paragraph to the document. And then I use that position to edit.
Is there easy way to find location of paragraphs, after the pdf is generated?
Should I stop using paragraphs and position, and switch to template with AcroForms for filling in data programatically?
Everything works, but It feels like ive selected the wrong approach.
Thank you in advance.

Related

iText - how to move down the current contents in a pdf

I have a requirement to add few lines at the top of an existing PDF.
I have done this using a PdfReader and a PdfStamper.
In order to have more space in the page header area, i need to move down the current contents by 1 or 2 lines.
Below is from the forum. but it doesn't solve the issue.
How to insert content in the middle of a page in a PDF using IText
Any suggestions?
-i can not upload the pdf or the image of the pdf because am a new user
Do I interpret your question correctly if I assume that you really want to move down everything on the page and add some lines above?
You can do that by changing the media box (and crop box and what other boxes might be explicitly defined for your page) and then add the few lines on top the same way you already do it now.
You can access those boxes in the respective page dictionary which you can retrieve via the PdfReader. Look up the PDF specification for details on those boxes.
Or do I interpret you incorrectly and you only want to move down some text while keeping existing headers and footers in place? In that case Alexis' answer to the other question you refer to still holds.

Highlighting a string in a pdf iphone

I'm developing a book app.My client has provided all the contents of pdf.
I have already implemented all the contents of pdf to book.
But he wanted to highlight a text in that pdf.
The user would like the text to allow for highlighting (like if you're reading a paper book).
Is this possible? Can anyone help me on this, please?
Thanks in advance.
Theoretically yes.. depends on a bit hacking and other things, for example fonts used in the PDF. Have a look at PdfKitten, their demo project can find text in a PDF and highlight it. That should give you a first pointer on how to highlight. If you want to the user to highlight with the touches you would need to be able to transform locations of touches into the PDF to determine where exactly the user touched, but it should be possible.

Adding buttons to PDF documents in iPhone App

I'm writing an iPad app where the user will open PDF documents.
I want to substitute some unique texts with clickable buttons.
ie. if there is a text: "Please click a button" I want to put a button instead (or over) the word "button".
What is the right way to do this?
Thanks!
There is not a straight forward solution to it. What you need to do is following :
1) Search for text 'button'. PDF document text extraction needs to happen before this. Performace depends on how you do this. Some PDF parsers create a marker and while rendering the PDF it indexes the text data of PDF. So searching becomes faster. There can be many more approaches :)
2) Get the bounding box coordinates of the text in screen space.
2) Now draw a platform widget on this coordinate.

How can you select text in a PDF displayed within a UIWebView?

Can anybody tell me if it is necessary to select the text in a PDF file loaded within a UIWebView, or is it selected on its own?
If it's not selected, how can we implement the selection of text within such a PDF?
The UIWebView actually draws the PDF pages as images so you don't have access to individual items (textfields, images etc.)
Highlighting isn't by far a trivial task. One solution would be to use the CGPDFScanner to parse the page's stream and figure out how to concatenate the transformations for the text operators (TJ, Tj, Tm, Tc, Tw etc.) in order to get the individual glyph positions. If you succeed in doing that the rest should be pretty straight forward.

WordProcessingML shapes problem

I am currently working on exporting information from browser to word document. I am having information which contains colors and shapes. Now when I export them using wordprocessingML I am able to export text that are highlighted in colors. But I am also having certain text in browser that are encapsulated with circles ad box. I found that using VML we can render shapes. But I want the shapes to be in the specified x-axis and y-axis, so that it renders the text properly. Is there is any way to specify co-ordinates in shapes using keywords like "this.x", "this.y". Something similar to this to render the shapes on the text. I am not sure whether I am clear. Would like to discuss more about this.
I have found that solution for this problem. We can use "auto" keyword which can be used to find the relative position of the shapes in the worddocument according to the flow of the page. Now my question when I passed margin-left:auto, margin-top;auto, I was able to display the shapes in the right dimension. But I have also included text inside the text attribute which I want the shapes to be overlapped. I am getting shapes aside the text, not wrapping the text. Does anyone know the solution, I can try it. I find it really interesting to work on wordml.