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

Free Support Forum - aspose.com

With Aspose PDF Java API, How Can I fill the form fields while preserving extended features

What I am trying to do is similar to this https://docs.aspose.com/display/pdfnet/Add%2C+Delete+and+Modify+Form+Field#Add,DeleteandModifyFormField-PreserveExtendedRightswhenWorkingwithForms

This link explains on how to do with NET API, but I need the similar thing with Java API.

(1) I can’t find corresponding article on the Java side, is this feature supported by Java API?
(2) I am currently using evaluation copy, which adds watermark. With this eval version, can i test the preserving extended feature?


This feature is supported in Aspose.PDF for Java API. Please try the code as follows:

// Instantiate Document instance
Document pdfDocument = new Document("c:\\temp\\document.pdf");
// Get values from all fields
for (Field formField : (Iterable<Field>) pdfDocument.getForm())
    // If the fullname of field contains A1, perform the operation
    if (formField.getFullName().contains("A1"))
        // Cast form field as TextBox
    	TextBoxField textBoxField = (TextBoxField)formField;
        // Modify field value
// Save the updated document in save FileStream

You can get a 30 day temporary license for the testing purposes. A temporary license is a time-restricted full license that lets you test every aspect of the API before buying it. Please refer to these helping links: Get a 30 day Temporary License and Apply License to Aspose.PDF for Java API

Thanks for the response. I will get 30 day license. the above code doesn’t work with eval version.

Also do you have the code that does the same thing for byte array, not file stream?


You can convert bytes to the file stream or vice versa in Java as follows:

File file = new File("/temp/abc.txt");
//init array with file length
byte[] bytesArray = new byte[(int) file.length()]; 
FileInputStream fis = new FileInputStream(file);
fis.read(bytesArray); //read file into bytes[]
return bytesArray;


String str = "Welcome to awesome Java World";
byte[] content = str.getBytes();
int size = content.length;
InputStream is = null;
byte[] b = new byte[size];
is = new ByteArrayInputStream(content);

Please let us know in case of any more assistance or queries.

Thanks for the reply,
I wasn’t asking Java question.
This is about Aspose PDF API.
The top example loads the file and save to the same file name.

If I use ByteArrayStream or Anyother Input Stream when creating the document, how it gets saved??
That is my question. Is there different API to handle this situation.
I see one example with “saveIncrementally” from another post for incremental update ( Pdf Incremental Updates)
To preserve “extended features”, incremental update is basic thing to do. This function “saveIncrementally” would still preserve “extended features”? The person who posted the question seems to have wanted the same thing that I am trying to achieve. He claimed that it worked in the latest codes. But I am still having a trouble.

May be it is related to another question, Aspose API supports the PDF file created by LiveCycle? ( I think it is in hybrid format ). Maybe that is why I am having difficulty to make the sample code working.

I think we can close this. The sample code from other post seems working for binary output.
Thanks for all responses and support.


It is nice to hear from you that the problem has been resolved. Please feel free to let us know whenever you need any more assistance.