简体   繁体   中英

Converting HTML String into pdf

I am converting an HTML string into a pdf document using following code.

It converts the HTML to pdf well enough, but when I add the an img tag to the HTML it does not render the image in the pdf .

Here is the code I am using.

 var htmlString="<H1>Hello This is Text</H1> <img src='zid.png'>";

 function generatePDF(htmlString) {
    if(htmlString!=null) {
       alert("Html String: "+htmlString);
        Ti.App.fireEvent("generatePDFfromString",{
                           "htmlString":htmlString,
                           "fileName":'MyFileName.pdf'
                         });
    }
 };

 function gotPDF(filePath){
    alert("Html String: "+filePath);
    Ti.App.fireEvent("sendEmail",{
                       "fileURL":filePath,"subject":'My File Subject',
                       "messageBody":"",
                       "toReceipients":[""]
                     });
 }

Try this:

Before

 var htmlString="<H1>Hello This is Text</H1> <img src='zid.png'>";

After

 var htmlString="<H1>Hello This is Text</H1> <img src='zid.png'/>";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM