Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
CSS vendor prefixes, sometimes called CSS browser prefixes, are used in CSS property names to implement experimental or pre-release CSS features that are not yet standardized or may have limited support in certain browsers. Vendor prefixes are used to identify specific browsers or browser versions that support these features.
Major browser vendors commonly use the following prefixes to implement nonstandard CSS features:
According to the CSS specification, CSS vendor-specific extensions must start with a dash or underscore and have the following format:
['-' or '_'] + [vendor identifier] + ['-'] + [name]
For example, the -webkit-border-radius is a vendor-prefixed property that allows you to round the corners of elements to create a visually appealing and modern design in WebKit-based browsers, such as Chrome.
The prefix that is used by Aspose.HTML library looks like -aspose- and gives you some experimental features. Following is a list of CSS functions that can be enabled by using -aspose- prefix:
| Name | Description |
|---|---|
| currentPageNumber | This function returns the number of the current rendering page. |
| totalPagesNumber | This function returns the number of the total pages in the document. |
The next code snippet demonstrates how to use CSS extensions to create custom marks on document margins:
getService() method to fetch the User Agent service implementation from the configuration.setUserStyleSheetU() method to define CSS rules for page margins, content placement, and styling for page counters and titles.device) method to convert the HTML to XPS. 1// Add custom page margins, header, and footer using CSS @page rules in Aspose.HTML for Java
2
3// Initialize a configuration object
4Configuration configuration = new Configuration();
5
6// Get the User Agent Service
7IUserAgentService userAgent = configuration.getService(IUserAgentService.class);
8
9// Set a style of custom margins and create marks on it
10userAgent.setUserStyleSheet(
11 "@page {\n" +
12 " /* Page margins should be not empty in order to write content inside the margin-boxes */\n" +
13 " margin-top: 1cm;\n" +
14 " margin-left: 2cm;\n" +
15 " margin-right: 2cm;\n" +
16 " margin-bottom: 2cm;\n" +
17 " /* Page counter located at the bottom of the page */\n" +
18 " @bottom-right {\n" +
19 " -aspose-content: \"Page \" currentPageNumber() \" of \" totalPagesNumber();\n" +
20 " color: green;\n" +
21 " }\n" +
22 " /* Page title located at the top-center box */\n" +
23 " @top-center {\n" +
24 " -aspose-content: \"Hello, World Document Title!!!\";\n" +
25 " vertical-align: bottom;\n" +
26 " color: blue;\n" +
27 " }\n" +
28 "}");
29// Initialize an HTML document
30HTMLDocument document = new HTMLDocument("<div>Hello, World!!!</div>", ".", configuration);
31
32// Initialize an output device
33XpsDevice device = new XpsDevice("output.xps");
34
35// Send the document to the output device
36document.renderTo(device);You can download the complete examples and data files from GitHub.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.