Repository navigation
Library API es
kudryavskiy_rv edited this page Jul 5, 2026
·
1 revision
use office_print::config::{ConvertOptions, Format, OutputFormat};
// Archivo → PDF
let result = office_print::convert("informe.docx").unwrap();
std::fs::write("informe.pdf", result.as_pdf_bytes().unwrap()).unwrap();
// Archivo con opciones
let options = ConvertOptions {
output_format: OutputFormat::Png,
..Default::default()
};
let result = office_print::convert_with_options("entrada.pptx", &options).unwrap();
// Bytes → PDF
let result = office_print::convert_bytes(&data, Format::Xlsx, &options).unwrap();
// IR → PDF directo
let pdf = office_print::render_document(&ir_document).unwrap();match &result.output {
OutputData::Pdf(bytes) => {
std::fs::write("salida.pdf", bytes).unwrap();
}
OutputData::Raster { pages, format } => {
for (i, page) in pages.iter().enumerate() {
let ext = match format { OutputFormat::Png => "png", OutputFormat::Jpeg => "jpg", _ => "bin" };
std::fs::write(format!("pagina-{}.{}", i + 1, ext), page).unwrap();
}
}
}| Campo | Tipo | Defecto | Descripción |
|---|---|---|---|
output_format |
OutputFormat |
Pdf |
Pdf, Png, Jpeg
|
jpeg_quality |
u8 |
92 |
Calidad JPEG 1–100 |
paper_size |
Option<PaperSize> |
None |
A4, Letter, Legal, Custom
|
landscape |
Option<bool> |
None |
Horizontal |
pdf_standard |
Option<PdfStandard> |
None |
A2b para PDF/A |
pdf_ua |
bool |
false |
PDF/UA-1 |
tagged |
bool |
false |
PDF estructurado |
font_paths |
Vec<PathBuf> |
[] |
Dirs. fuentes adicionales |
sheets |
Option<Vec<String>> |
None |
Filtro hojas XLSX |
slide_range |
Option<SlideRange> |
None |
Rango diapositivas |
streaming |
bool |
false |
Modo streaming XLSX |
streaming_chunk_size |
Option<usize> |
None |
Tamaño de chunk |
match office_print::convert("entrada.docx") {
Ok(result) => { /* usar */ }
Err(ConvertError::UnsupportedEncryption) => eprintln!("Archivo cifrado"),
Err(ConvertError::UnsupportedFormat(f)) => eprintln!("Formato desconocido: {f}"),
Err(e) => eprintln!("Fallo de conversión: {e}"),
}📖 English Docs