Hello,
I was tring to add manually a formfield and it works… I wish also to specify the font type , size, etc… how can I do that? I’ve tried with the link on the wiki for formatting a textbox but it uses section and pdfdocument won’t accept it…here’s my code
Here I add 5 section to a certain position
Document pdfDocument = new Document(“C:/temp/ProveCampiModulo/input.pdf”);
double pixel = ConvertMmToPoints(3);
double llx = ConvertMmToPoints(201);
double urx = ConvertMmToPoints(105);
double lly = ConvertMmToPoints(233);
double ury = lly + pixel;
for (int n = 1; n <= 5; n++)
{
//create a field
TextBoxField textBoxField = new TextBoxField(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(llx, lly, urx, ury));
textBoxField.PartialName = “riga”+ n.ToString();
textBoxField.Value = “TextBox” +n.ToString();
textBoxField.ReadOnly = true;
//add field to the document
pdfDocument.Form.Add(textBoxField, 1);
lly -= pixel;
ury -= pixel;
}
//save modified PDF
pdfDocument.Save(“C:/temp/ProveCampiModulo/output.pdf”);
Another question is possible giving coordinates to check if there are some items inside the rectangle I define?
Thanks
Hi Paolo,
Thanks for using our products.
Once you have added the form field inside the document, you may consider using Font property of FormFieldFacade Class which provides the capability to change/specify the font information for the form field. It also supports the capability to change/set the font size of Form field. Please take a look over the following code snippet to accomplish your requirement.
[C#]
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>
<![endif]–>
//create FormEditor object and open PDF file
FormEditor form = new FormEditor("input.pdf", "output.pdf");
//create a new facade object
FormFieldFacade facade = new FormFieldFacade();
facade.Font = Aspose.Pdf.Facades.FontStyle.Helvetica;
//assign the facade to form
form.Facade = facade;
//close and validate the modification like this:
form.Save();
Now concerning to your requirement "Another question is possible giving coordinates to check if there are some items inside the rectangle I define?" I am afraid this feature is currently not supported. However for the sake of correction, I have logged this requirement as PDFNEWNET-34120 in our issue tracking system under investigations category. We will further look into the details of this requirement and will keep you updated on the status of correction. We are sorry for this inconvenience.
Hello,
this is while editing…during the definition phase it’s not possible?
Hi Paolo,
As far as I can understand from your requirement, you need to add Form fields to existing PDF documents and you need to specify the Font name and other formatting information for form field. In current scenario, I would suggest you to simply try using FormEditor class to add form fields to the PDF document and specify the field formatting information during the same process. Please visit the following links for further details on
- Add Form Field in an Existing PDF file
- Decorate All Fields of a Particular Type in an Existing PDF File
- FormEditor Class
In case I have not properly understood your requirement, please share some further details. We are sorry for this inconvenience.
Hi Paolo,
Thanks for your patience.
I am pleased to share that the feature requested earlier to extract form fields in a particular rectangular region has been implemented and its resolution is included in the upcoming release version of Aspose.Pdf for .NET 7.3.0. In order to fulfill this requirement, we have introduced the GetFieldsInRect(Rectangle rect)
method to Aspose.Pdf.Form
class.
Please take a look at the following code snippet for better understanding.
[C#]
Document doc = new Document("d:/pdftest/FDA-3500_508+No+submit_Filled.pdf");
Aspose.Pdf.InteractiveFeatures.Forms.Field[] fields = doc.Form.GetFieldsInRect(new Aspose.Pdf.Rectangle(35, 703, 126, 753));
The issues you have found earlier (filed as PDFNEWNET-34120) have been fixed in Aspose.Pdf for .NET 7.3.0.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.