Article Mode Custom CSS Guide
In Just One Page PDF, Smart Article Extraction (Article Mode) cleans and restructures a webpage into an independent layout flow, enabling full support for the CSS Paged Media specification and extension-specific variables.
⚠️ Scope & Usage Limitations:
- Article Mode Only: The
@pagemargin boxes, dynamicstring()variables, and pagination counters covered in this guide take effect exclusively in Article Mode and are not parsed in original-webpage rendering modes such as Full Page Print.- Do Not Combine with Multi-Page Frame Templates: This custom CSS syntax cannot be used together with Multi-Page Frame Templates. If you enable custom
@pagemargin boxes or dynamic variables, ensure no Multi-Page Frame Template is stacked on top to avoid pagination and header/footer rendering conflicts.
1. How to Open the Custom CSS Editor
Section titled “1. How to Open the Custom CSS Editor”
- In the preview screen after entering Article Mode, locate the custom css option in the right-hand settings panel and click the gear icon next to it.
- In the pop-up editor, write your CSS directly—or click the preset dropdown menu in the bottom-left corner to quickly apply and customize built-in presets (such as
advanced,clean,custom remote font, etc.). - Once finished, click OK in the bottom-right corner to preview the layout changes in real time.
2. Core Syntax & Variable Quick Reference
Section titled “2. Core Syntax & Variable Quick Reference”1. Page Margin Boxes
Section titled “1. Page Margin Boxes”Inside an @page rule, you can insert content directly into the surrounding margin regions of each page, most commonly:
- Top Regions:
@top-left,@top-center,@top-right - Bottom Regions:
@bottom-left,@bottom-center,@bottom-right
@page { margin: 0.8in; /* Set page margins to leave space for headers and footers */
@bottom-right { /* Bottom-right styling and content */ }}2. Page Numbering: Standard Counters vs. Extension-Specific Variables
Section titled “2. Page Numbering: Standard Counters vs. Extension-Specific Variables”Inside the content property, there are two ways to insert page numbers—pay close attention to the difference between the functions:
| Implementation | Syntax | Meaning | Specification |
|---|---|---|---|
Counters (counter()) | counter(page) / counter(pages) | Current page / Total pages | Standard CSS Paged Media syntax |
Dynamic Variables (string()) | string(sitePage) / string(sitePages) | Current page / Total pages | Just One Page PDF exclusive variables |
@page { @bottom-right { /* Method 1: Standard CSS counters */ content: counter(page) " / " counter(pages);
/* Method 2: Extension-exclusive string() variables */ /* content: string(sitePage) " / " string(sitePages); */
font-size: 10pt; color: #666666; }}3. Dynamic Section & Metadata Variables (string() Function)
Section titled “3. Dynamic Section & Metadata Variables (string() Function)”Using string(variableName), you can automatically pull section headings or article metadata from the current page to create book-grade dynamic headers and footers.
(1) Heading Variables: head1–6 vs. section1–6
Section titled “(1) Heading Variables: head1–6 vs. section1–6”The extension provides two sets of hierarchical heading variables suited for webpages with varying structural rigor:
head1–head6(Strict Tag Mapping): Maps strictly to the actual HTML tags<h1>–<h6>in the article body. If a heading level is skipped in the source HTML (for example, jumping directly from<h1>to<h4>), the intermediatehead2andhead3variables remain empty.section1–section6(Smart Level Normalization): Dynamically normalizes heading levels based on the headings actually present in the body, automatically eliminating skipped hierarchy gaps.- Example: If a webpage only uses
<h1>,<h4>, and<h5>, the system automatically normalizes them tosection1(<h1>),section2(<h4>), andsection3(<h5>). For webpages with inconsistent heading markup, thesectionseries is recommended.
- Example: If a webpage only uses
(2) Summary of Article Metadata & Page Number Variables
Section titled “(2) Summary of Article Metadata & Page Number Variables”| Variable Name | Syntax | Extracted Value | Common Use Cases |
|---|---|---|---|
title | string(title) | Main article title | Book / long-article top header |
subtitle | string(subtitle) | Article subtitle | Secondary top header text |
author | string(author) | Article author | Byline header or copyright footer |
hostname | string(hostname) | Source website domain (e.g., example.com) | Clean copyright attribution |
url | string(url) | Full source webpage URL | Footer source link |
sitePage | string(sitePage) | Current page number (extension-exclusive) | Custom page number text |
sitePages | string(sitePages) | Total page count (extension-exclusive) | Custom total pages text |
3. Complete Ready-to-Use Example
Section titled “3. Complete Ready-to-Use Example”Paste the following code into the custom css editor to generate a publication-style layout featuring the article title, dynamic top-level section heading, source URL, and page numbers:
@page { margin: 0.8in;
/* Top-left: Display main article title */ @top-left { content: string(title); font-size: 9pt; color: #888888; }
/* Top-right: Dynamically display current top-level section (auto-normalizes skipped H tags) */ @top-right { content: string(section1); font-size: 9pt; color: #555555; }
/* Bottom-left: Display source domain and full URL */ @bottom-left { content: string(hostname) " | " string(url); font-size: 8pt; opacity: 0.55; }
/* Bottom-right: Display current page and total pages using extension variables */ @bottom-right { content: "Page " string(sitePage) " of " string(sitePages); font-size: 9pt; font-weight: bold; }}
body { line-height: 1.6; color: #222222;}