Ответ 1
Существует новое облачное решение jQuery +, которое превратит любую HTML-страницу и ее CSS (включая правила печати) в PDF. Решение настроено для печати любой области вашей веб-страницы, просто сообщите Formatter, какой элемент контейнера вы хотите распечатать, а библиотека сделает все остальное. То, что вы получаете назад, является встраиваемым PDF файлом или бэкэндом, который отталкивает PDF файл для загрузки.
Здесь ваша библиотека (GitHub):
https://github.com/Xportability/css-to-pdf
Здесь ваша скрипка:
http://jsfiddle.net/kstubs/jrtM5/
Здесь рабочая демонстрация:
http://xep.cloudformatter.com/doc/
В настоящее время нет инструкций по использованию, но следующие вместе с образцами (источник просмотра) должны быть довольно понятными (смотрите кнопки "Печать" ), и здесь более или менее дополнительные параметры/параметры, которые используют метод Format понимает.
options
{
pageWidth: "8.5in",
pageHeight: "11in",
pageMargin: ".25in",
pageMarginTop: "1in",
pageMarginRight: "1in",
pageMarginBottom: "1in",
pageMarginLeft: "1in",
render: ("none"|"newwin<default>"|embed"|"download<default IE>"),
foStyle: {
// puts fo style attributes on the root, ex. fontSize:14px
foStyleName: 'value', ...
}
}
Вот список атрибутов CSS, которые в настоящее время поддерживаются.
[
'lineHeight',
'alignmentBaseline',
'backgroundImage', 'backgroundPosition', 'backgroundRepeat', 'backgroundColor',
'baselineShift',
'border',
'borderWidth', 'borderColor','borderStyle',
'borderTop','borderLeft','borderRight','borderBotttom',
'borderTopWidth','borderTopStyle','borderTopColor',
'borderBottomWidth','borderBottomStyle','borderBottomColor',
'borderLeftWidth','borderLeftStyle','borderLeftColor',
'borderRightWidth','borderRightStyle','borderRightColor',
'borderCollapse',
'clear', 'color',
'display', 'direction', 'dominantBaseline',
'fill', 'float',
'fontStyle', 'fontVariant', 'fontWeight', 'fontSize', 'fontFamily',
'listStyleType', 'listStyleImage', 'letterSpacing',
'marginTop', 'marginBottom', 'marginLeft', 'marginRight','orphans',
'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft',
'pageBreakAfter', 'pageBreakBefore',
'tableLayout',
'textAlign', 'textAnchor','textDecoration', 'textIndent', 'textTransform',
'verticalAlign',
'widows', 'wordSpacing', 'width'
]
Надеюсь, это поможет!