Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Jun 1, 2024
1 parent c08c151 commit c5dcbb8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
3 changes: 1 addition & 2 deletions cli/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ pub fn convert_(

let tree = usvg::Tree::from_str(&svg, &options).map_err(|err| err.to_string())?;

let pdf =
svg2pdf::to_pdf(&tree, conversion_options, page_options);
let pdf = svg2pdf::to_pdf(&tree, conversion_options, page_options);

std::fs::write(output, pdf).map_err(|_| "Failed to write PDF file")?;

Expand Down
15 changes: 3 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ pub fn to_pdf(
conversion_options: ConversionOptions,
page_options: PageOptions,
) -> Vec<u8> {
let mut ctx = Context::new(
tree,
conversion_options,
);
let mut ctx = Context::new(tree, conversion_options);
let mut pdf = Pdf::new();

let dpi_ratio = 72.0 / page_options.dpi;
Expand Down Expand Up @@ -327,16 +324,10 @@ pub fn to_pdf(
/// std::fs::write("target/embedded.pdf", pdf.finish())?;
/// # Ok(()) }
/// ```
pub fn to_chunk(
tree: &Tree,
conversion_options: ConversionOptions
) -> (Chunk, Ref) {
pub fn to_chunk(tree: &Tree, conversion_options: ConversionOptions) -> (Chunk, Ref) {
let mut chunk = Chunk::new();

let mut ctx = Context::new(
tree,
conversion_options,
);
let mut ctx = Context::new(tree, conversion_options);
let x_ref = tree_to_xobject(tree, &mut chunk, &mut ctx);
ctx.write_global_objects(&mut chunk);
(chunk, x_ref)
Expand Down
5 changes: 1 addition & 4 deletions src/util/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ pub struct Context {
}

impl Context {
pub fn new(
tree: &Tree,
options: ConversionOptions
) -> Self {
pub fn new(tree: &Tree, options: ConversionOptions) -> Self {
let mut ctx = Self {
ref_allocator: RefAllocator::new(),
options,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[allow(unused_imports)]
use {
crate::FONTDB,
crate::render_pdf,
crate::FONTDB,
crate::{convert_svg, run_test_impl},
pdf_writer::{Content, Finish, Name, Pdf, Rect, Ref, Str},
std::collections::HashMap,
Expand Down

0 comments on commit c5dcbb8

Please sign in to comment.