Существует ли способ распечатать заголовок/нижний колонтитул веб-страницы на каждой странице?

Помните, что @@ ИДЕНТИФИКАЦИОННЫЕ ДАННЫЕ возвращают последний раз созданные идентификационные данные для Вашего текущего соединения, не обязательно идентификационные данные для недавно добавленной строки в таблице. Необходимо всегда использовать SCOPE_IDENTITY () для возврата идентификационных данных недавно добавленной строки.

39
задан Carvell Fenton 14 December 2011 в 20:29
поделиться

4 ответа

It can be done with tables -- and I know I'm going to risk a downvote by suggesting using tables for layout - but we are talking IE6 here which isn't known for its fantastic CSS support :-)

If you set a CSS style as follows:

thead { display: table-header-group; }
tfoot { display: table-footer-group; }

Then when you create your HTML, render your body as:

<body>
<table>
   <thead><tr><td>Your header goes here</td></tr></thead>
   <tfoot><tr><td>Your footer goes here</td></tr></tfoot>
   <tbody>
     <tr><td>
     Page body in here -- as long as it needs to be
     </td></tr>
   </tbody>
</table>
</body>

Yes it's not good (tables vs CSS), it's not ideal, but (importantly for you) it does work on IE6. I can't comment on Firefox as I've not tested it there, but it should do the job. This will also handle differnt sized pages, differing font sizes, etc. so it should "just work".

If you want the header and footer to appear on printed media only, then use the @media parameters to do the right thing:

@media print {
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }
}
@media screen {
    thead { display: none; }
    tfoot { display: none; }
}

Note
As of July 2015, this will still only work in Firefox and IE. Webkit-based browsers (cf. Chrome, Safari) have long standing bugs in their issue trackers about this if anyone feels strongly enough to vote on them:

The comments below this question tell me this is now resolved in Chrome. I haven't checked myself :-)

The original bugs against Chrome (for reference) are:

34
ответ дан 27 November 2019 в 02:48
поделиться

попытаться создать (rtf | pdf) документ для печати

3
ответ дан 27 November 2019 в 02:48
поделиться

Я бы предложил разделить страницу в таблице и добавить часть заголовка в первую строку и часть нижнего колонтитула в последнюю строку. Содержимое строк между первой и последней строками можно изменять динамически, поэтому вы получите постоянный верхний и нижний колонтитулы на нужных страницах.

----------
ROW1    HEADER
----------
ROW2   
 Insert dynamic contents here
ROW N-1
----------
ROW N Footer

5
ответ дан 27 November 2019 в 02:48
поделиться

Это будет работать в некоторых браузерах, но не во всех. Я не думаю, что существует элегантное кроссбраузерное решение

Включите желаемый нижний колонтитул / заголовок печати в блоки div на странице (в этом примере div id = 'printableFooter')

В файл css экрана поместите:

#printableFooter {display: none;}

В файле css для печати:

#printableFooter {display: block; position: fixed; bottom: 0;}
6
ответ дан 27 November 2019 в 02:48
поделиться