use printpdf::*;
#[test]
fn set_text_cursor_text_is_on_page_not_at_bottom() {
let ph = 841.89_f32; let ops = vec![
Op::StartTextSection,
Op::SetFont { font: PdfFontHandle::Builtin(BuiltinFont::Helvetica), size: Pt(24.0) },
Op::SetTextCursor { pos: Point { x: Pt(50.0), y: Pt(760.0) } }, Op::ShowText { items: vec![TextItem::Text("Near the top".to_string())] },
Op::EndTextSection,
];
let mut doc = PdfDocument::new("t");
doc.pages.push(PdfPage::new(Mm(210.0), Mm(297.0), ops));
let svg = doc.pages[0].to_svg(&doc.resources, &PdfToSvgOptions::default(), &mut Vec::new());
let seg = svg.split("<text").nth(1).expect("a <text> element");
let m = seg.split("matrix(").nth(1).expect("a matrix()").split(')').next().unwrap();
let f: f32 = m.split_whitespace().nth(5).unwrap().parse().unwrap();
assert!(f > 0.0 && f < ph * 0.5, "text baseline f={f} should be near the top, not the bottom (ph={ph})");
}