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

WIP: [debug] Adding debug log for debugging pdf preview crash #59

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion 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::Medium => render_cfg.thumbnail(50),
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
Loading