Wrap text written within user defined area in pdf - itext

We have a requirement where user wants to write some content from the db to selected areas in pdf. We provide this option by asking the user to upload pdf to the system, after drawing rectangular markups within. Later he can define rules as to what content he can write to the defined area. We use iText for all operations like reading coordinates of the drawn markups, writing content to the defined area.
Now the challenge is that we need to wrap the text within the area that the user has defined. We use the ColumnText class to write the content. Is there anyway we can wrap the text within the area? Posting this query from mobile. So couldn't upload any helpful code.

Related

Is there any way to create a PDF from a widget using Flutter?

I did some research and find out that you can create PDF with images or texts or by exporting the screenshot, but I want to create much more like in the image below:
So what I want to achieve is to have a good resolution for PDF to print the PDF as a book after this. The physical book has a lot of pages and my client wants to create the virtual one.
So, I have the design (as you can see in the image), but I still need to create some text fields, signature and some logic in the widget.
How can I export after that to a one page PDF for every widget?
Screenshot won't be enough because I think it doesn't have a good quality and ofc the text and everything else won't be suited in the phone screen.
I am thinking to use the basic design and to add manually by code the texts, but I don't know how to export this to a PDF after that.
Of Course! The pdf package is a great start.

single layer/flatten pdf file ITEXTSHARP

My Desktop App is creating a single page pdf with itextsharp library.There are 40 Passport size photos with names under it on a single page.
I need to flatten this pdf page (with 40 photos) as one Image while creating the pdf,currently there are 40 individual photos on the pdf page.I presume it would create around 80 layers by default which would take a very high time on ripping this file for printing on a press.
I dont want to make all the 40 images as one jpeg externally using GDI+ and then lay it in pdf.
I have seen many options using stamper and reading the created pdf file to flatten.Is there a way while creating the pdf i can create a flattened file.
Your understanding of flattening a PDF is completely wrong. The concept of flattening a PDF means: removing all interactivity. For instance: you have a PDF file with form fields. The content of these form fields can be changed in Adobe Reader. When you flatten such a form, you take away the form fields and replace the field content by actual content of the page. The result is a flat PDF in the sense that people can no longer change the content of the fields.
You presume that having multiple pictures on a single page in a PDF means that there are multiple layers in that PDF. Your understanding of layers in a PDF is completely wrong. Layers is a word that is used in many different contexts. For instance, when working with optional content groups (OCG), people often refer to layers.
The concept of layers as you may know it from Photoshop doesn't really exist in PDF. Content is added in a stream. Whatever content is added first, can be covered by content that comes after. You want to pro-process the content by removing all the content that isn't visible in the hope that the PDF will be printed faster. You want to achieve that by replacing many different image objects by one image.
Your assumption that this can be done with iText is wrong. iText doesn't convert PDF to an image. This is outside the scope of what iText is written for.
If you want to add X images as 1 single image using iText, then you have to process the X images into 1 single image before you add the images to the PDF. You need image manipulation software, because iText won't do what you're asking for.

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.

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.