2021-12-17 18:03:02 +02:00
|
|
|
use docx_rs::*;
|
|
|
|
|
|
|
|
pub fn main() -> Result<(), DocxError> {
|
|
|
|
let path = std::path::Path::new("./output/hyperlink.docx");
|
|
|
|
let file = std::fs::File::create(&path).unwrap();
|
|
|
|
Docx::new()
|
2022-07-06 04:47:15 +03:00
|
|
|
.add_paragraph(Paragraph::new().add_hyperlink(
|
|
|
|
Hyperlink::new("anchor", HyperlinkType::Anchor).add_run(Run::new().add_text("Hello")),
|
|
|
|
))
|
2021-12-17 18:03:02 +02:00
|
|
|
.add_bookmark_start(1, "anchor")
|
|
|
|
.add_paragraph(
|
|
|
|
Paragraph::new()
|
2022-07-06 04:47:15 +03:00
|
|
|
.add_hyperlink(
|
|
|
|
Hyperlink::new("https://google.com", HyperlinkType::External)
|
|
|
|
.add_run(Run::new().add_text(" World")),
|
|
|
|
)
|
2021-12-17 18:03:02 +02:00
|
|
|
.page_break_before(true),
|
|
|
|
)
|
|
|
|
.add_bookmark_end(1)
|
|
|
|
.build()
|
|
|
|
.pack(file)?;
|
|
|
|
Ok(())
|
|
|
|
}
|