[英]ABCpdf not applying inline css styles
在我的aspx頁面中,我具有以下CSS的腳本
<style type="text/css">
.subcontainer{margin: 0 auto; padding-top: 20px}
.hide-val{display:none;}
</style>
在瀏覽器中,頁面加載正常,沒有顯示帶有hide-val
類的div,但是當我使用AddImageURL樣式時,未應用。
Doc theDoc2 = new Doc();
theDoc2.HtmlOptions.UseScript = true;
theDoc2.HtmlOptions.Media = MediaType.Print;
theDoc2.HtmlOptions.InitialWidth = 1048;
//for multiple page
theDoc2.Rect.Inset(10, 30);
theDoc2.Page = theDoc2.AddPage();
int theID2;
theID2 = theDoc2.AddImageUrl(urlToHtmlPage);
while (true)
{
theDoc2.FrameRect(); // add a black border
if (!theDoc2.Chainable(theID2))
break;
theDoc2.Page = theDoc2.AddPage();
theID2 = theDoc2.AddImageToChain(theID2);
}
for (int i = 1; i <= theDoc2.PageCount; i++)
{
theDoc2.PageNumber = i;
theDoc2.Flatten();
}
//end multipage
theDoc2.Save(HttpContext.Current.Server.MapPath("htmlimport.pdf"));
theDoc2.Clear();
我已經看到很多類似的問題,但是我沒有找到答案
如何在文檔中添加CSS樣式?
由於您指定了theDoc2.HtmlOptions.Media = MediaType.Print;
,您是否嘗試過將CSS標記為@media print
?
像這樣:
<style type="text/css">
@media print {
.subcontainer{margin: 0 auto; padding-top: 20px}
.hide-val{display:none;}
}
</style>
或者,取出theDoc2.HtmlOptions.Media = MediaType.Print;
行theDoc2.HtmlOptions.Media = MediaType.Print;
我尚未證實這一點,但值得一試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.