简体   繁体   English

与其他页面相比,第一页显示不同的HTML标头

[英]Display different HTML header on first page compared to other pages

I'm using a HTML to PDF Library called Nreco to convert HTML Pages to PDF. 我正在使用一个名为Nreco的HTML to PDF库将HTML Pages转换为PDF。 The task includes setting the same header on every page, apart from the first page which contains the Recipient Address as part of the header. 该任务包括在第一页上设置相同的标头,除了包含收件人地址作为标头一部分的第一页之外。

I'm wondering what is the best way to make it possible. 我想知道什么是使之成为可能的最佳方法。 The Nreco C# library allows setting a Document wide header that remains the same depending on every page. Nreco C#库允许设置一个文档宽标题,该标题保持不变,取决于每个页面。

I'm a HTML/CSS amateur. 我是HTML / CSS业余爱好者。 My thinking is: it should be possible somehow (conditional statement) to add the Recipient Address only on the first header, and omit it on every other header instance. 我的想法是:应该有可能(有条件的声明)仅在第一个标头上添加收件人地址,而在其他所有标头实例上忽略它。 However, I can't find a way to access the page counter in the header code, also there is no option to specify a conditional operator inside the HTML/CSS. 但是,我找不到在标头代码中访问页面计数器的方法,也没有在HTML / CSS内部指定条件运算符的选项。

Code: 码:

 <td colspan="4" rowspan="11" width="100%" class="textTopLeft">
                        <p>
                            {billingRecipient1}
                            <br>
                            {billingRecipient2}
                            <br>
                            {billingRecipient3}
                            <br>
                            {billingRecipient4}
                        </p>
 </td>

I found a solution. 我找到了解决方案。

I wrapped my block in a div called headerStyle . 我将代码块包装在名为headerStyle的div Then added an ID to my inner block called dynamicSection . 然后在我的内部块中添加一个名为dynamicSection的ID。 After this I added this script to hide the dynamicSection block on any pages apart from the first one. 之后,我添加了此脚本以在除第一个页面之外的任何页面上隐藏dynamicSection块。

 var y = document.getElementsByClassName('headerStyle');
 for (var j = 0; j < y.length; j++) {
      if (vars[x[2]] != 1) {                     
          document.getElementById('dynamicSection').style.cssText = 'display: none;';
      }
 }

Hope this helps someone out! 希望这可以帮助某人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 XMLWorkerHelper将html页面转换为pdf仅产生前2页 - XMLWorkerHelper convert html page into pdf produces only first 2 pages 使用 AJAX 在不同的 html 页面上显示搜索栏和搜索结果 - Display searchbar and search results on different html pages using AJAX 保存用户名,并在其他页面上显示 - Save username, and display on other pages WPF MainWindow显示其他页面 - WPF MainWindow to display other pages 动态添加Response.Redirect到同一页面上其他页面上的不同按钮 - Adding an Response.Redirect to the same page dynamically to different Buttons on different other pages LinkButton Commandargument 给出所有其他页面中第一页的值(Gridview 分页) - LinkButton Commandargument is giving values of the first page in all the other pages (Gridview pagination) 在列表中找到与其第一项相比不同的项目 - Finding the different items in a list compared to its first item of the list 如何在Windows Phone 8的WebView中根据月份的日期和时间显示不同的html页面: - How to Display different html pages according to date and time of the month in a webview in windows phone 8: Rotativa显示HTML页眉和页脚 - Rotativa Display HTML header and footer 登录时显示不同的页面 - on login display a different page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM