Convert base64 to pdf

0

I have in my application a function that converts the pdf to base64 and saves it to the database, so I need to return this base64 and show the contents of the original file.

    $('#form-job').submit(function(e) {
    e.preventDefault();
    console.log('aqui');
    var inputs = $(e.target).find('[name]').serializeArray();

    var reader = new FileReader(),
        file = $('#resume')[0];

    if (!file.files.length) {
        alert('no file uploaded');
        return false;
    }

    var url = "http://localhost:5000/api/curriculum";
    reader.onload = function () {
        var data = reader.result,
            base64 = data.replace(/^[^,]*,/, '');

        inputs.push({name:'resume', value: base64});                        

        $.ajax({
            url: url,
            type: "POST",
            dataType: "JSON",
            data: inputs,
            success: function (response) {
                $(".contato-quad-formulario-right-enviar").hide()
                $(".contato-quad-formulario-right-enviar-sucesso").show()
                $(".contato-quad-formulario-right, .contato-quad-formulario-left").fadeTo("slow", 0.33);
             }
        });
    };
    reader.readAsDataURL(file.files[0]);                
});

It's a matter for the company to do this, save on base64 and then show the original content. Now that comes my problem, I can not in any way show the original content. How can I do to create a pdf from base64 that is returned to me. If it helps I can return the value saved in the database as buffer or in base64 which is better?

    
asked by anonymous 25.04.2018 / 21:51

0 answers