2

I have the following HTML -

            htmlBody +=                     '<table width="100%" style="background:#16284c;max-width: 900px;margin: auto;">';
        htmlBody +=                         '<tr>';
        htmlBody +=                             '<td style="text-align: center; vertical-align: middle;">';
        htmlBody +=                                 '<H2 style="color:#ffffff;">PBM Partner Information</H2>';
        htmlBody +=                             '</td>';
        htmlBody +=                         '</tr>';
        htmlBody +=                     '</table>';

I convert the HMTL to PDF using the following:

Blob.toPDF(htmlBody);

Then I add the PDF to an email as an attachment.

   List<Messaging.EmailFileAttachment> attachments = new List<Messaging.EmailFileAttachment>();


    Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();

    efa.setBody(Blob.toPDF(htmlBody));
    efa.setContentType('application/pdf');
    efa.setFileName('test.pdf');
    attachments.add(efa);

    email.setFileAttachments(attachments);

The PDF loads, but the CSS is gone. Why?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.