Free Support Forum - aspose.com

Regarding Aspose.pdf

Are there plans to allow for the dynamic creation of form fields inside newly created Pdf or existing PDF?

Actually i am searching for some .net source or Api that is having a UI from where I can add form field like (Text box, dropdownlist,checkbox ), Important requirement Is that that source should have some UI where I can able to add form field through UI.

I already gone through https://github.com/aspose-pdf/Aspose.PDF-for-.NET
But this source is not having any UI controls thats is the problem.
Pls replay me as soon as possible.

@Rajesh2312

Aspose.PDF for .NET does not offer and UI based editor or control to integrate within applications. You can however only use it in the codebehind to perform operation over PDF documents. In case you need assistance while using the API in codebehind, please feel free to let us know.

OK, can u help me out I am having one more doubt.
I am adding 2 text at the same time with for loop, my label variavle is having (text1,text2)
but while doing so its saving only text2 in my pdf, My requirement is that how I can create ( TextFragment textFragmentadd = new TextFragment(label[i]):wink: dynamically for the first and second Text.

Example:

TextFragment textFragmentadd= new TextFragment(“Hi!”);
textFragmentadd.Position = new Position(20, 600-i);
// Set text properties
textFragmentadd.TextState.FontSize = 12;
textFragmentadd.TextState.Font = FontRepository.FindFont(“TimesNewRoman”);
textFragmentadd.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);
textFragmentadd.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);

                    // Append the text fragment to the PDF page
                   
                    textBuilderadd.AppendText(textFragmentadd);
        .
        .
        .
        .
TextFragment n = new TextFragment("n");

n .Position = new Position(20, 600-i);
// Set text properties
n .TextState.FontSize = 12;
n .TextState.Font = FontRepository.FindFont(“TimesNewRoman”);
n .TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);
textFragmentadd.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);

                    // Append the text fragment to the PDF page
                   
                    textBuilderadd.AppendText(n );
-------------------------------------------------------------------------------------------------------------------
Pls replay asap.

Here is my code:

: 

 string[] label = s.a.Split(',');  //contain text1,text2
                    TextBuilder textBuilderadd = new TextBuilder(pdfPage);
                    for (int i = 0; i < label.Length; i++)
                    {
                        TextFragment textFragmentadd = new TextFragment(label[i]);
                        textFragmentadd.Position = new Position(20, 600-i);
                        // Set text properties
                        textFragmentadd.TextState.FontSize = 12;
                        textFragmentadd.TextState.Font = FontRepository.FindFont("TimesNewRoman");
                        textFragmentadd.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);
                        textFragmentadd.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);



                        // Append the text fragment to the PDF page
                       
                        textBuilderadd.AppendText(textFragmentadd);
                    }

@Rajesh2312

You are noticing only one text fragment in output because both texts are being added at same position. Please use following code snippet to change position for every new text:

Document document = new Document();
string[] label = ("text1,text2").Split(',');  //contain text1,text2
Page pdfPage = document.Pages.Add();
TextBuilder textBuilderadd = new TextBuilder(pdfPage);
double x = 20, y = 600;
for (int i = 0; i < label.Length; i++)
{
 TextFragment textFragmentadd = new TextFragment(label[i]);
  textFragmentadd.Position = new Position(x, y);
  // Set text properties
  textFragmentadd.TextState.FontSize = 12;
  textFragmentadd.TextState.Font = FontRepository.FindFont("TimesNewRoman");
  textFragmentadd.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);
  textFragmentadd.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);
  // Append the text fragment to the PDF page
  textBuilderadd.AppendText(textFragmentadd);
  y += 15;
}
document.Save(dataDir + "output.pdf");

output.pdf (28.2 KB)

HI, do you have any sample source where we can add formfield with UI controls without using hardcode c# code.

@Rajesh2312

We regret that Aspose.PDF does not provide any UI control to integrate within your application. It can only be used in the codebehind to process PDF files with your desired fucntionality. In case you need further information, please feel free to let us know.

Hi asad,

I am trying to create form field with aspose pdf, just want to know its possible to create document image.png (24.9 KB) like this. Just want to know is this requirement can be satisfied by aspose pdf or not.

Thanks & Regards
Rajesh

@Rajesh2312

The sample image shows tables and checkboxes inside table cells and Aspose.PDF offers the functionality to add tables as well as checkboxes inside table. Please check following articles for more information: