Create a fillable PDF from a MS Word file

Hi and thanks for a great product!

Is it possible using aspose to create a fillable pdf-form from an existing MS Word file that contains form-fields?

BR Lars

@lars.olsson Sure, you should simply enable PdfSaveOptions.PreserveFormFields option. For example see the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Isert different types of form fields
builder.Write("CheckBox form field: ");
builder.InsertCheckBox("check1", false, 12);
builder.Writeln();

builder.Write("TextInput form field: ");
builder.InsertTextInput("text1", TextFormFieldType.Regular, "", "some default text", 0);
builder.Writeln();

builder.Write("ComboBox form field: ");
builder.InsertComboBox("combo1", new string[] { "item1", "item2", "item3" }, 0);

PdfSaveOptions opt = new PdfSaveOptions();
opt.PreserveFormFields = true;

doc.Save(@"C:\Temp\out.pdf", opt);
1 Like

Thanks! I will test this!

1 Like

Hi!
I had tried with PreserveFormFields = true.
And it works. But we also need option (Compliance = PdfCompliance.PdfA1a).
In combination of these will make it not working.
Is there any fix to make it to works?

BR Lars

@lars.olsson PDF/A allows interactive forms but they should be read-only. So currently Aspose.Words does not export form field into PDF document with PDF/A compliance.

Thanx for fast reply.
We will see what we will want to do now.

BR Lars

1 Like

HI we have tested the feature to convert a MS word based form to a fillable PDF. And have a few questions. (see attached sample files)

  • The text-fields generated are rather small (looks the same way in the word file but there they are expanded when text is added). Is this some thing that you can change in the generated pdf?

  • Some fields are not supported (date and image) is this a limitation in the conversion to pdf or in the pdf-format?

Exampel file - forms (orörd).docx (33.3 KB)
Exampel file - forms (orörd).pdf (41.7 KB)

Thanks

@lars.olsson

  1. You can fill the text input controls with some dummy content to make them look wider in PDF. But there is no way to grow the text input fields in PDF while typing, since in PDF position of all content is fixed.
builder.InsertTextInput("text1", TextFormFieldType.Regular, "", "                              ", 0);

MS Word uses a series of non-breaking spaces as a default filler for legacy text input fields.

  1. We will consider supporting date and image picker content controls upon exporting to PDF. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

    Issue ID(s): WORDSNET-24983,WORDSNET-24984

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

Hi and thanks for all your assistance!

We have noted one major issue in the conversion. The text fields in the generated PDF do not support all characters. for exampel ÅÄÖ in the swedish language cant be added to the field.

@lars.olsson Unfortunately, I cannot reproduce the problem on my side. I have tried generating a document using the following simple code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Write("TextInput form field: ");
builder.InsertTextInput("text1", TextFormFieldType.Regular, "", "test", 0);

PdfSaveOptions opt = new PdfSaveOptions();
opt.PreserveFormFields = true;

doc.Save(@"C:\Temp\out.pdf", opt);

And then type the mentioned character in Acrobat reader. The characters are shown fine: out.pdf (66.2 KB)

Also, I have tried putting the mentioned characters ad default value:

builder.Write("TextInput form field: ");
builder.InsertTextInput("text1", TextFormFieldType.Regular, "", "ÅÄÖ", 0);

And still the characters are shown properly: out_aw.pdf (23.4 KB)

That is weird :slight_smile:

We use aspose words 22.8 and genrate the PDF fil from an existing MS Word file. Could any of these differences effect?

I also note that when opening the file that you generated (out.pdf) in MS Edge the behavior is that the characters are displayed correct initially but when i modify the text in the field several characters are not displayed.

They seam to be there, i can select and copy them but they have a style that makes the invisible. This can be due to limitations in MS Edge as a PDF-viewer but it is commonly used. What’s your opinion on this?

Bets regards
Lars

@lars.olsson It looks like MS Edge can use only glyphs of the fonts embedded into the PDF document. So it displays only characters, which glyphs are there in the font subset embedded into the document. The problem does not occur if embed full fonts:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Write("TextInput form field: ");
builder.InsertTextInput("text1", TextFormFieldType.Regular, "", "test", 0);

PdfSaveOptions opt = new PdfSaveOptions();
opt.PreserveFormFields = true;
opt.EmbedFullFonts = true;

doc.Save(@"C:\Temp\out.pdf", opt);

Looks like a glitch or limitation in MS Edge.

1 Like

Hi not sure if this is the proper channel, but salse directed my to the support channel. If i want to know more what we can get from a priority support contract regarding the issues mentioned above, who should i talk to?

@lars.olsson You can learn about priority support polices here:
https://helpdesk.aspose.com/kb/index.php

I have consulted with developer responsible for these features development. Currently the issues are planned for development in Q2-Q3 2023. But purchasing priority support might shift the estimate.

Hello, are there any updates in your plan to improve the support to generate fillable pdf:s from a ms Word form?

From what i can see they where planed for late 2023 but the issues are still active. Correct?

Best regards Lars

@lars.olsson I am afraid implementation of this feature has been postponed due to low demand of this feature and is not yet scheduled for development. Please accept our apologies for your inconvenience.