We are using PDFNet::Convert module to convert the pdf with form to xod and later using the xod in the pdf viewer to render the form in the mobile viewer. When we try to respond to the form, certain field are not rendered at all.
The flow is as given.
1. The pdf with form is uploaded to the server
2. Server converts the pdf to xod and saves it in the file store
3. The saved xod is fetched by the mobile and rendered in the webviewer
4. User responds to the fields and send back the xfdf data to the server
var contentWindow = frame.contentWindow,
annotationManager = contentWindow.readerControl.docViewer.getAnnotationManager(),
formData = annotationManager.exportAnnotations();
updateFormDataInServer(formData);
5. Server accepts the xfdf and escapes the form special characters so that postgresql can save it as xml
#custom attribute setter
def update_form_data(form_data, user_id)
normalized_form_data = REXML::Text.normalize(form_data)
update(form_data: normalized_form_data, updated_by_id: user_id)
end
6. User views the form fetched
Server:
# model getter
def form_data
normalized_form_data = read_attribute(:form_data)
REXML::Text.unnormalize(normalized_form_data) unless normalized_form_data.nil?
end
Client:
$(document).on('documentLoaded', function() {
var docViewer = readerControl.docViewer;
docViewer.setInternalAnnotationsTransform(function(originalData, callback) {
var customData = (window.ControlUtils.getCustomData()) || originalData; //customData is xfdf saved in the server, use it if available else use the pristine form data
callback(customData);
});
});
7. The updated field values are absent along with some other fields/widgets.
A thorough inspection of the html obtained in 3rd step shows all the field/widgets missing from the rendered pdf. Only the background image is visible.