pub struct PageSettings {
pub width: HwpUnit,
pub height: HwpUnit,
pub margin_left: HwpUnit,
pub margin_right: HwpUnit,
pub margin_top: HwpUnit,
pub margin_bottom: HwpUnit,
pub header_margin: HwpUnit,
pub footer_margin: HwpUnit,
pub gutter: HwpUnit,
pub gutter_type: GutterType,
pub mirror_margins: bool,
pub landscape: bool,
}Expand description
Physical page dimensions and margins for a section.
Contains 8 HwpUnit fields covering all geometry a page needs.
Copy because it is 32 bytes – small enough to pass by value.
§Presets
PageSettings::a4()– A4 (210 mm x 297 mm) with 20 mm marginsPageSettings::letter()– US Letter (8.5“ x 11“) with 1“ margins
§Examples
use hwpforge_core::PageSettings;
use hwpforge_foundation::HwpUnit;
let custom = PageSettings {
width: HwpUnit::from_mm(148.0).unwrap(),
height: HwpUnit::from_mm(210.0).unwrap(),
..PageSettings::a4()
};
assert!(custom.width.to_mm() < 149.0);Fields§
§width: HwpUnitPage width.
height: HwpUnitPage height.
margin_left: HwpUnitLeft margin.
margin_right: HwpUnitRight margin.
margin_top: HwpUnitTop margin.
margin_bottom: HwpUnitBottom margin.
header_margin: HwpUnitHeader margin (distance from page top to header baseline).
Footer margin (distance from page bottom to footer baseline).
gutter: HwpUnitBinding gutter width. Defaults to 0 (no gutter).
gutter_type: GutterTypeGutter position type. Defaults to LeftOnly.
mirror_margins: boolWhether to mirror left/right margins on even pages (for bound documents).
landscape: boolWhether this section uses landscape orientation.
When true, the encoder outputs landscape="NARROWLY" (한글’s reversed convention).
Width/height should remain in portrait order (e.g. 210x297 for A4);
한글 handles the rotation internally.
Implementations§
Source§impl PageSettings
impl PageSettings
Sourcepub fn a4() -> Self
pub fn a4() -> Self
A4 paper (210 mm x 297 mm) with 20 mm margins, 10 mm header/footer.
These are the de-facto default settings for Korean government documents and the HWP editor’s default.
§Examples
use hwpforge_core::PageSettings;
let a4 = PageSettings::a4();
assert!((a4.width.to_mm() - 210.0).abs() < 0.1);
assert!((a4.height.to_mm() - 297.0).abs() < 0.1);Sourcepub fn letter() -> Self
pub fn letter() -> Self
US Letter (8.5“ x 11“) with 1“ margins, 0.5“ header/footer.
§Examples
use hwpforge_core::PageSettings;
let letter = PageSettings::letter();
assert_eq!(letter.width.as_i32(), 61200); // 8.5 * 7200
assert_eq!(letter.height.as_i32(), 79200); // 11 * 7200Sourcepub fn printable_width(&self) -> HwpUnit
pub fn printable_width(&self) -> HwpUnit
Returns the printable width (page width minus left and right margins).
§Examples
use hwpforge_core::PageSettings;
let a4 = PageSettings::a4();
let printable = a4.printable_width();
// 210mm - 20mm - 20mm = 170mm
assert!((printable.to_mm() - 170.0).abs() < 0.5);Sourcepub fn printable_height(&self) -> HwpUnit
pub fn printable_height(&self) -> HwpUnit
Returns the printable height (page height minus top and bottom margins).
Trait Implementations§
Source§impl Clone for PageSettings
impl Clone for PageSettings
Source§fn clone(&self) -> PageSettings
fn clone(&self) -> PageSettings
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PageSettings
impl Debug for PageSettings
Source§impl Default for PageSettings
impl Default for PageSettings
Source§impl<'de> Deserialize<'de> for PageSettings
impl<'de> Deserialize<'de> for PageSettings
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for PageSettings
impl Display for PageSettings
Source§impl JsonSchema for PageSettings
impl JsonSchema for PageSettings
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for PageSettings
impl PartialEq for PageSettings
Source§impl Serialize for PageSettings
impl Serialize for PageSettings
impl Copy for PageSettings
impl Eq for PageSettings
impl StructuralPartialEq for PageSettings
Auto Trait Implementations§
impl Freeze for PageSettings
impl RefUnwindSafe for PageSettings
impl Send for PageSettings
impl Sync for PageSettings
impl Unpin for PageSettings
impl UnwindSafe for PageSettings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.