After flattening pdf form on WebViewer html5 form fields remain visible

46 views
Skip to first unread message

Jose Alberto Guastavino

unread,
Feb 7, 2017, 1:08:47 PM2/7/17
to PDFTron WebViewer
How can I hide html5 form fields after flattening a pdf form in WebViewer Online

The only way I found is to not allow annotations but this can be setted when WebViewer initiates only and no in an open session.

The code I wrote is
var simpleFlattenPDFFFileGenerator = function* () {
var pdfDoc= yield readerControl.docViewer.getDocument().getPDFDoc();
var fdfDoc = yield pdfDoc.fdfExtract(0);
var am = readerControl.docViewer.getAnnotationManager();
var xfdfString = am.exportAnnotations();
var fdfDoc= yield PDFNet.FDFDoc.createFromXFDF(xfdfString);
yield pdfDoc.fdfMerge(fdfDoc);
yield pdfDoc.flattenAnnotations(true);
var bufferMemoryFlattened = yield pdfDoc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized);
var pdfBlob = new Blob([bufferMemoryFlattened], {
type: 'application/pdf'
});
uploadPDFBlob(pdfBlob);
// Refresh the cache with the newly updated document
readerControl.docViewer.refreshAll();
// Update viewer with new document
readerControl.docViewer.updateView();
}

After running it the WebViewer shows the flattened document but the html5 fields remain over it. How can I disable / hide them?


Thanks

Justin Jung

unread,
Feb 8, 2017, 3:26:50 PM2/8/17
to PDFTron WebViewer
Hello Jose,

You can try the following code to hide html5 fields.

$(document).on('documentLoaded', function() {
  readerControl
.docViewer.on('pageComplete', function(e, pageIndex) {
    $
('#pageWidgetContainer' + pageIndex).find('div').css('display', 'none');
  
});
});

Justin Jung
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages