newXHR.addEventListener('load', reqListener);
newXHR.open('POST', 'http://nfse.vitoria.es.gov.br/aberto/op/imprimirNfe.cfm', false);
var jsonData = { codNfe: vlNota };
var formattedJsonData = "codNfe=" + vlNota;
newXHR.setRequestHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8');
newXHR.setRequestHeader('Cache-Control', 'max-age=0');
newXHR.setRequestHeader('Upgrade-Insecure-Requests', '1');
newXHR.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
newXHR.responseType = "arraybuffer";
}catch(ex) {
console.log('Erro ao abrir a URL');
return false;
}
This code returns me a pdf, I wanted to create a file with the data I get from this request