Skip to content

Invoice PDF

Works with the Invoice PDF.

HTTP: GET

Gets the PDF Invoice for a give invoice internal id.

Base URL

https://{{accountid}}.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=customscript_prac_api_invoicepdf&deploy=customdeploy_prac_api_invoicepdf_v1

Required Parameters

Name Value Notes
script customscript_prac_api_invoicepdf
deploy customdeploy_prac_api_invoicepdf_v1
custparam_id {{integer}} The internal id of the invoice you are retrieving.

Optional Parameters

Name Value

Response Information

IMPORTANT: Response content-type returned is 'text/plain' and contains a Base64 encoded string. The consumer/client must convert the Base64 back to Binary.

BONUS: Node.js App to Convert Base64 to Binary
const fs = require('fs');
const path = require('path');

// Function to convert base64 string to binary and save to a file
function base64ToBinary(base64String, outputFilePath) {
    // Decode base64 string to binary data
    const binaryData = Buffer.from(base64String, 'base64');

    // Write binary data to a file
    fs.writeFile(outputFilePath, binaryData, (err) => {
        if (err) {
            console.error('Error writing binary data to file:', err);
        } else {
            console.log('Binary data saved to', outputFilePath);
        }
    });
}

// Read base64 string from input.txt
const inputFilePath = path.join(__dirname, 'input.txt');
fs.readFile(inputFilePath, 'utf8', (err, base64String) => {
    if (err) {
        console.error('Error reading base64 string from file:', err);
        return;
    }

    // Convert base64 string to binary and save to output file
    const outputFilePath = 'output.pdf'; // Change the file extension as needed
    base64ToBinary(base64String, outputFilePath);
});