不能应用CSS到HTML字符串 [英] Cannot apply CSS to the html string

查看:172
本文介绍了不能应用CSS到HTML字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想evoPDF在我的asp.net应用程序集成。我送的html的一部分,从我的html文件,通过AJAX的onclick。一切工作,直到FIE这部分。现在,当我从调用API EvoPdf这些方法。

I am trying to integrate evoPDF on my asp.net app. I am sending part of html from my html file onclick through ajax. Everything works fie till this part. Now, when I invoke these methods from EvoPdf API.

 1. GetPdfBytesFromHtmlStream(Stream, Encoding,urlbase)

 2. SavePdfFromHtmlStringToFile(String html,string filename,urlbase)

我的HTML块,我送的东西像

My html chunk I am sending is something like

 <ol class = "lol">
         <li> HEY </li>
         <li> Now </li>

  </ol>

这是在外部文件的CSS是一样的东西。

The Css which is in the external file is something like

 .lol {

      background-color: red;

  }

根据文档的第三个参数必须是您提取HTML的大块的originial的Html的完整URL。我上传我的应用程序在网络,因为试图本地主机/ 3232没有工作。但是,我不能看到生成的HTML应用任何CSS。在本文档中,他们还建议追加

According to the documentation the third argument must be the full url of the originial Html where you extracted the chunk of the html. I uploaded my app in the web since trying localhost/3232 didn't work. But, I can't see any CSS being applied in the generated Html. In the documentation they also recommended to append

       <HEAD> <BASE HREF="full url to your html file"> </HEAD>

和,使用此方法。

        pdfConverter.GetPdfBytesFromHtmlString(String html);

我没有试过以上CSS适用。任何想法....

Nothing I tried above applies CSS. Any thoughts....

推荐答案

虽然它可能有与evoPDF外部文件的HTML,我不建议这样做。而不只是内联的样式在文档的头部。当我们建立了就业2.0 PDF生成,我记得网址,必须是活的URL,后面的Web服务器,在相同的目录结构不只是相对链接。还有一个在EVO PDF超时,可能会导致图像的损失,如果加载时间过长,这也起到与内嵌的一切更好。

While it's possible to have the html in an external file with evoPDF, I don't recommend it. Instead just inline the styles in the head of the document. When we were setting up the PDF generator for Careers 2.0, I remember that the urls had to be live urls, behind a web server, not just relative link in the same directory structure. There is also a timeout in evo pdf that can cause loss of images if loading takes too long, which also plays nicer with inline everything.

我也推荐过它完全有效的HTML,不只是你需要生成视图中的片段。幕后(在我们至少evoPDF的版本),它只是一个提升浏览器实例,并采取截图。他们提供一点点不同,具体取决于文档类型。

I also recommend passing it fully valid html, not just the snippets you need to generate the view. Behind the scenes (in our version of evoPDF at least), it's just hoisting a browser instance and taking a screenshot. They render a little differently depending on the doctype.

这篇关于不能应用CSS到HTML字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆