We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Fillable word docs to Fillable pdfs

I have been investigating the best way to create fillable PDF documents from fillable word documents. I have found that when I do this the resulting PDF does in fact have field codes: (java code)

Document wordDoc = new Document(wordFileName);
PdfSaveOptions so = new PdfSaveOptions();
so.setPreserveFormFields(true);
wordDoc.save(workingDir + intermedPdfName,so);

The problem I’m having is that I can’t make the PDF fields sized the way I need them. For example, the default sizes for the text fields in MS Word are kind of small, and I’d like to make them bigger. I have thought of work arounds where I could write text into the field (in word) to make the field length render larger, and then using aspose PDF remove the text from the fields. I’ve also thought of various other hacks to accomplish my requirements. The requirement, by the way is to create MS Word and PDF renditions of the same form, with fillable fields in each, that look as close as possible to each other, and that preserve the field length in the PDF document. Ideally, I’d even be able to specify some fields as multiline fields within a bounding box in the PDF form.

Any ideas or recommendations as to the best approach?

Thanks

Hi Brian,


Thanks for your inquiry. We will appreciate it if you please share you sample DOC(X) document, we will test the scenario at our end and will update you accordingly.

Meanwhile, as a workaround you can use Aspose.Pdf to change field size as per your requirement. You have to get field rec and resize it accordingly. Please check following code snippet for the purpose. Hopefully it will help you to accomplish the task.

//open document<o:p></o:p>

Document pdfForm = new Document("Form.pdf");

//get a field. field

TextBoxField textBoxField = (com.aspose.pdf.TextBoxField)pdfForm.getForm().get("Textbox1");

//modify field properties

//textBoxField.Value = "";

textBoxField.setMultiline(true);

//change the field size. In Aspose.Pdf, 1 inch = 72 points

com.aspose.pdf.Rectangle rec1 = new com.aspose.pdf.Rectangle(textBoxField.getRect().getLLX(), textBoxField.getRect().getLLY(), textBoxField.getRect().getURX() + 40, textBoxField.getRect().getURY() + 40);

textBoxField.setRect(rec1);

//save updated document

pdfForm.save("Form_output.pdf");


Please feel free to contact us for any further assistance.

Best Regards,

Thanks. I’ve attached a document we are working with, as well as the
generated PDF document. There are a number of problems, which are
pretty clear in looking at the document and the result:

1. New-style fields in text boxes or tables do not get converted to fillable pdf fields.
2. No way to specify that a field is multi-line programmatically
3. No way to set field size in the PDF automatically to fill bounds, i.e. within text box.

Can you think of a work-around or other procedure to get past the above?

What about an approach like I outline at the bottom of the test doc, using a known tag to indicate where a field should be inserted? Can you show me how to find the element that contains the known tag, i.e. a table cell or a text box, and get the position and bounds so that I could create a field inside the PDF document when generating it? In other words, what about creating an intermediate PDF version that contains the tags instead of the fields, and creating the PDF fields by referencing the bounds of the tag in the word document while creating the PDF?

Thanks!

Hi Brian,

I can see the fillable text boxes and check boxes in the output PDF and size of these fields is also same. Content controls are not supported in Word to PDF conversion and that is why you do not see those fields in the output PDF.

You can use Aspose.Pdf for Java to search for the tags and there position from your PDF as you can see at Search and Get Text from PDF Pages and use the code shared by Tilal to insert multiline fields.

Best Regards,