Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
[debug] Adding debug log for debugging pdf preview crash
Browse files Browse the repository at this point in the history
  • Loading branch information
tuancoltech committed Dec 11, 2023
1 parent 1b3a451 commit ad5ae9f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
use image::DynamicImage;
use once_cell::sync::OnceCell;
use pdfium_render::prelude::*;
use log::debug;

static PDFIUM: OnceCell<Pdfium> = OnceCell::new(); // static initializers must impl Sync + Send

Expand Down Expand Up @@ -36,17 +37,23 @@ pub fn render_preview_page<R>(data: R, quailty: PDFQuality) -> DynamicImage
where
R: Read + Seek + 'static,
{
debug!("render_preview_page PDF 1");
let render_cfg = PdfRenderConfig::new();
debug!("render_preview_page PDF 2");
let render_cfg = match quailty {
PDFQuality::High => render_cfg.set_target_width(2000),
PDFQuality::Medium => render_cfg,
PDFQuality::Low => render_cfg.thumbnail(50),
}
.rotate_if_landscape(PdfBitmapRotation::Degrees90, true);
debug!("render_preview_page PDF 3");

if PDFIUM.get().is_none() {
debug!("render_preview_page PDF 4");
initialize_pdfium();
debug!("render_preview_page PDF 5");
}
debug!("render_preview_page PDF 6");
PDFIUM
.get()
.unwrap()
Expand Down

0 comments on commit ad5ae9f

Please sign in to comment.