You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: pdf.rs
    path of file: ./repos/bilibili_comics_downloader/src/lib
    
    the code of the file until where you have to start completion: use printpdf::{Image, Mm, PdfDocument};
use std::path::PathBuf;

const H: f64 = 297.;
// 297mm
const W: f64 = 210.;

fn calc_transformation(img_w: u32, img_h: u32, dpi: f64) -> printpdf::ImageTransform {
    // 变换方法: 中心点对齐 不允许出界 保持比例
    let img_w = img_w as f64;
    let img_h = img_h as f64;

    // 将图片的宽高转换为 mm
    let img_w_mm = img_w / dpi * 25.4;
    let img_h_mm = img_h / dpi * 25.4;

    let w = W;
    let h = H;
    let scale = if img_w > img_h {
        w / img_w_mm
    } else {
        h / img_h_mm
    };
    let x = (w - img_w_mm * scale) / 2.;
    let y = (h - img_h_
    
fn calc_transformation(img_w: u32, img_h: u32, dpi: f64) -> printpdf::ImageTransform {
    // 变换方法: 中心点对齐 不允许出界 保持比例
    let img_w = img_w as f64;
    let img_h = img_h as f64;

    // 将图片的宽高转换为 mm
    let img_w_mm = img_w / dpi * 25.4;
    let img_h_mm = img_h / dpi * 25.4;

    let w = W;
    let h = H;
    let scale = if img_w > img_h {
        w / img_w_mm
    } else {
        h / img_h_mm
    };
    let x = (w - img_w_mm * scale) / 2.;
    let y = (h - img_h_mm * scale) / 2.;
    printpdf::ImageTransform {
        translate_x: Some(Mm(x)),
        translate_y: Some(Mm(y)),
        rotate: None,
        scale_x: Some(scale),
        scale_y: Some(scale),
        dpi: Some(dpi),
    }
}