Best way to represent a form that has dynamic fields and fielgroups

Hi Team,

We are licensed users of Aspose from a reputed company.

We have a scenario where we can have forms that are created by users - i.e, there is no set template and they can use any combination of fields and even group multiple fields into fieldgroups. These may appear in any order and there can also be nested field groups.

Which service of aspose do you recommend to achieve the exact replica of what we see in the ui? All fieldroups must be enclosed in a rectangle too. We have tried using tables in aspose.pdf - but it was difficult to achieve columnWidths that increase/decrease as per the content it holds. Now we are exploring on the table format in aspose.words. Could Aspose.Forms have something that could help? The pdf that we generate should not be editable.

Our input is in the form of a structure that tells us which row and column to place a field or fieldgroup in, there are no coordinates available. Our main issue was maintaining readability in case there is more than 1 nested fieldgroup.

But it would be great to know what Aspose thinks about the best way forward.

Please let me know if you need any more info, glad to provide it.

@SumithaS,

I hope I understand this correctly. The user has a canvas where they draw fields with values, and then the idea is to represent this on a pdf. There is nothing that will automatically help you do this but you can have lots of control when placing fields.

NOTE: Words documents are flow-type vs Pdf documents are box-type. You have to pick which one do you think will be better for what you want to do(if you want to use Aspose.Words API, you need to go to this forum Aspose.Words Product Family - Free Support Forum - aspose.com).

If you pick Aspose.Pdf API, this is what I would do if I were the developer.

If I got the idea right, I would suggest limiting the canvas where the users draw to the size of the page you want to print. If printing is not an option, then you can start by increasing the page size to match up the canvas where the user draws the fields.

Once we have the size done right for drawing the fields, you will see documentation about text fields and how to draw them on a specific place on the page. FormEditor Class|Aspose.PDF for .NET

Specifically, here you will see an example of code where it shows the rectangle where you want to place on the page. Add PDF Form Fields|Aspose.PDF for .NET .This is what you need to do in order to mimic the user’s placement, as well as the size of the field, which was the issue with the column width you had with the table, if I understood that part correctly.
Since this is not automatic, you will have to set an arbitrary size for the row you can calculate where on the page you want this. Again, this is not simple, as is completely manual. We have to do this in order to replicate the layout the client designed(that was why was so important the first step about the page size before starting placing the fields).

Once you have decided on the size of the field row, you can decide on the tab space for nesting. All of this will have to be done manually. If it was a table, you could have created tables inside tables, but if you want placement control, the best is to use rectangle coordinates, as you can exactly pick where to place a field.

In order to avoid edition, you can flatten your fields once you are done with designing and filling the values. Here is a code sample to achieve that: How to Flatten PDF Form Fields in C#

Sorry for the length of the post but I wanted to be clear that the scenario won’t be simple but can be achieved with the tools given by Aspose.Pdf API.

1 Like

Thank you so much Carlos for your quick and detailed reply and for all the info!

I understand our scenario is pretty complicated! Unfortunately, what complicates it even more is that we have no control over the canvas size the user has set since it is done in another unrelated module. I have attached a word doc with the json structure for your reference for the data that the kind of data that could come into our application. So the canvas size we could work with would just be A4 in either portrait or landscape mode. I checked this link from the link you provided: Add PDF Form Fields|Aspose.PDF for .NET But we can’t really be sure of the coordinates here plus we create the pdf on the fly, and would not be

If you check the structure, we would need to match the Row and Column provided in renderSpecification object of the respective field groups or fields.
We don’t really have control over or the knowledge of the coordinates on the page that might look similar to how they have placed the structure in the UI.

I have also attached a template that was created based on this json structure. But what i have shared is a very basic form.

I have tried to create a good representation using aspose.words, but our actual generated report is in pdf and i need to include these word sections within a pdf. Finding a hard time to do that.

I will keep exploring n aspose.words. Thank you for all your help!
If you have an idea on how to add a builder object inside an existing pdf page (not saved on local disk but in memory) please let me know!
Thank you!

FormDataJson.docx (11.7 KB)
sample.JPG (16.5 KB)

@SumithaS,

I think it can be done, but you will have to make custom code for that functionality. There is nothing automatic that I can think of. I imagine some sort of recursive algorithm that can be called by level.

Now, can you take a look at this? LINQ Reporting Engine API in C#|Aspose.Words for .NET

Not sure if it can help you with what you need to create(since I am not an expert with that tool), but check it out. If you think it can help, you can ask for support for that in the forum Aspose.Words Product Family - Free Support Forum - aspose.com

I know this is not the answer you were expecting, but if you have some specific thing you are having an issue with while developing your solution, let us know to see if we can help you with that.