Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8909801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:31:33+00:00 2026-06-15T03:31:33+00:00

I want to convert HTML emails into a PDF. I have written the following

  • 0

I want to convert HTML emails into a PDF. I have written the following piece of code.

      var txt = msgs[i].getBody();
      /* We need two blob conversions - one from text to HTML and the other from HTML to PDF */
      var blob = Utilities.newBlob(txt, 'text/html',"Test PDF");
      Logger.log(txt);
      var tempDoc = DocsList.createFile(blob);
      var pdf = tempDoc.getAs('application/pdf');
      pdf.setName('Email As PDF');
      DocsList.createFile(pdf);

The above piece of code first creates a Blob out of the HTML from a Gmail message and uses the getAs() function to convert it to a PDF. However, images in the HTML are not to be found in the PDF. Any ideas on how to get these images would be appreciated.
Any alternative ideas on how to convert a gmail message to PDF is also welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:31:35+00:00Added an answer on June 15, 2026 at 3:31 am

    Interesting problem. Makes sense as to why this doesn’t work – PDF conversion doesn’t bother “rendering” the HTML to go fetch the image src.

    I did a quick test and confirmed that Data URI’s (inline images without requiring a separate HTTP call) worked with images.

    So, one hacky solution could be go fetch the images and then convert them to Data URI. This has a few downsides – hard to find these images (regex would be fragile or not comprehensive), lots of UrlFetch calls (even with some caching, most automated email senders add trackers so that you end up re-fetching the same image) and slow.

    Convert –

    <img src="http://images.myserver.com/myimage.png..."/>

    To (you can check the content type dynamically as well)-

    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhE..."/>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert / transfer HTML Transitional Code into a MS-Word readable-format...pdf would
I want to convert following html code into continuous string using jquery/javascript. <ul> <li>one</li>
I have the following HTML: <label>Lobby Template:</label> I want to convert it to jquery
I want to convert local html file on iPhone to PDF document. I have
I want to convert a simple HTML table into PDF in the memory (not
I want to convert all texts in a string into html entities but preserving
I have some html files that I want to convert to text. I have
I want to convert plaintext to link for an input I have. The HTML
I want to use the Discount C-library to convert Markdown text into HTML. I
I want to convert html to pdf dynamically in objective c. what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.