Discussões
Renderizar PDF usando Suitelet e definir Nome do arquivo via SuiteScript
Aplica-se a
Produto: NetSuite 2020.1
Cenário
Renderizar uma string como PDF e definir o nome do arquivo quando baixado por Suitelet.
Solução
Implemente o seguinte código em um Suitelet:
function renderPDF(context){
var serverResponse = context.response; //Gets the response object
var testData = 'TEST BODY'; //Test string to be rendered as PDF
var filename = 'PurchaseOrder_123456.pdf'; //Sample File name to be set when downloaded
serverResponse.setHeader({
name: 'Content-disposition',
value: 'filename="' + filename + '"',
}); //sets the filename to the specified format or name
serverResponse.renderPdf({
xmlString: testData}); //renders the string as a PDF file
return;
}
Observações:
- Os cabeçalhos diferenciam maiúsculas de minúsculas
Rotulado:
0
Olá, bem-vind@!
Faça login
Para ver todos os detalhes, faça o login.
Cadastre-se
Não tem uma conta? Clique aqui para começar!