将字符串数据拆分为页面

时间:2012-09-24 10:49:52

标签: c# jquery webbrowser-control

我使用booklet plug in为我的Web Browser内容制作书籍翻转效果,所以每件事都很好。

我从db中检索我的文本数据我想编写一个函数,将文本(已经从db检索过)转换为页面,例如,如果我的文本数量是 大于页面,它将其余部分文本放在下一页中,依此类推。

Html代码

<html >
<head>
    <!-- page css -->
    <link href="Booklet%20-%20jQuery%20Plugin_files/base0000.css" type="text/css" rel="stylesheet" media="screen, projection, tv">
    <link href="Booklet%20-%20jQuery%20Plugin_files/booklet0.css" type="text/css" rel="stylesheet" media="screen, projection, tv">

    <!-- required files for booklet -->
    <script src="Booklet%20-%20jQuery%20Plugin_files/jquery00.js" type="text/javascript"></script>
    <script src="Booklet%20-%20jQuery%20Plugin_files/jquery-u.js" type="text/javascript"></script>
    <script src="Booklet%20-%20jQuery%20Plugin_files/jquery01.js" type="text/javascript"></script>
    <script src="Booklet%20-%20jQuery%20Plugin_files/jquery02.js" type="text/javascript"></script>
    <link href="Booklet%20-%20jQuery%20Plugin_files/jquery00.css" type="text/css" rel="stylesheet" media="screen, projection, tv">

    <!-- basic initialization -->
    <script type="text/javascript">
    function mm() {
        $('#mybook').booklet();
    };
    </script>
</head>
<body >
<div id="mybook">
<div>page 1 content<div>//If my page content was larger than page put rest of text to next page
<div>page 2 content<div>
<div>page 3 content<div>
.
.
.
<div>
</body>
</html>

我该怎么做?

1 个答案:

答案 0 :(得分:0)

据我所知,加载文档后你必须做这样的事情:

var bookDiv = yourWebBrowserControl.Document.GetElementById["mybook"];

IEnumerable<string> theBook = getTheDataFromDb();
var sites = SplitTheBookIntoSites();

foreach (var site in sites)
{
  var bookSiteDiv = yourWebBrowserControl.Document.CreateElement("div");
  bookSiteDiv.InnerText = theSite;
  bookDiv.AppendChild(bookSiteDiv);
}

要拆分字符串,您可以使用here提供的解决方案之一。为了在每个网站上拥有固定的字符串大小,您必须选择像Courier这样的monospace font