CSS不适用于从ABC pdf创建pdf

Ani*_*wal 3 .net c# asp.net abcpdf

问题:

我正在传递HTML并通过ABC pdf创建pdf.

但是CSS没有应用于内容,并且创建的pdf不是预期的.

这是我的代码可以请你建议问题是什么或我们如何应用CSS ...

    public static String CreateHtmlFile(String strHtmlCode)
    {
        String Modifiedhtml = @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""><html class="" _Telerik_IE9"" xmlns=""http://www.w3.org/1999/xhtml"">" + strHtmlCode;
        Modifiedhtml = Modifiedhtml.Remove(Modifiedhtml.IndexOf(@"//<![CDATA["), (Modifiedhtml.IndexOf("//]]>") - Modifiedhtml.IndexOf(@"//<![CDATA[")));
        string[] stringSeparators = new string[] { "PdfCreator" };
        var baseUrl = HttpContext.Current.Request.Url.AbsoluteUri.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries).First();
        Modifiedhtml = Modifiedhtml.Replace(@"href=""../", (@"href=""" + baseUrl));
        Modifiedhtml = Modifiedhtml.Replace(@"href=""/", (@"href=""" + baseUrl));
        Doc theDoc = new Doc();
        theDoc.HtmlOptions.UseScript = false;
        //theDoc.Width = 1125;
        String s = string.Empty;
        //s = File.ReadAllText(@"D:\test.html");
        theDoc.Page = theDoc.AddPage();
        int theID;
        theID = theDoc.AddHtml(strHtmlCode);
        //theID = theDoc.AddHtml(s);
        while (true)
        {
            theDoc.FrameRect(); // add a black border
            if (!theDoc.Chainable(theID))
                break;
            theDoc.Page = theDoc.AddPage();
            theID = theDoc.AddImageToChain(theID);
        }
        for (int i = 1; i <= theDoc.PageCount; i++)
        {
            theDoc.PageNumber = i;
            theDoc.Flatten();
        }
        theDoc.Save(@"D:\two\pagedhtml4.pdf");
        theDoc.Clear();
        return String.Empty;
    }
Run Code Online (Sandbox Code Playgroud)

strHtmlCode是我们必须以PDF格式转换的页面的HTML.

提前致谢

Ros*_*ser 5

从WebSupergoo文档页面的AddHtml功能:

将HTML样式文本块添加到当前页面.

HTML样式的文本并没有支持CSS.对于功能齐全的标准CSS,您需要AddImageHtml.