Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

823
Visualizações
html2pdf external image not showing

I have an MVC app utilizing html2pdf to convert html into a PDF document with javascript. The html that is being converted is a customer invoice with an image of their logo. We utilize Azure Blob storage to store our images. Since Azure blob storage is hosted all our images show by placing the URL of where it is located in Azure blob storage.

I have been able to convert the html to a pdf but the external url images are not displaying in the pdf, just a blank space shows up.

I am receiving this error:

Access to image at 'https://blob.core.windows.net/images/a5a1032bf7b3b0ae4f70/profile/2064/Transparent_Logo_Blue.png' 
from origin 'http://localhost:65426' 
has been blocked by CORS policy: 
No 'Access-Control-Allow-Origin' 
header is present on the requested resource.

I have enabled cors, enabled cross origin on the img tag. I have tried changin type: 'png' to jpg and jpeg. All with the same errors.

My code:

 function downloadPDF() {

        //var element = document.getElementById('invoice');
        //html2pdf(element);

        // Get the element to print
        var element = document.getElementById('invoice');

        // Define optional configuration
        var options = {
            filename: 'inv_' + $('#InvoiceMaster_InvoiceNumber').val() + '.pdf',
            image: { type: 'png', quality: 0.98 },
            html2canvas: { scale: 2, allowTaint: false, useCORS: true },
            jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
        };

        // Create instance of html2pdf class
        var exporter = new html2pdf(element, options);

        // You can also use static methods for one time use...
        options.source = element;
        options.download = true;
        /*html2pdf.getPdf(options);*/

    }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

May be it´s something related with azure blob access permissions.

I don´t know if it´s your case, but may be that you need to add some information in your header requests as it has been explained on that document.

https://docs.microsoft.com/en-us/rest/api/storageservices/preflight-blob-request

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda