Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created PDF has content, but is displayed empty with all tested PDF viewers. #120

Open
Michaelschnabel-DM opened this issue Sep 23, 2024 · 2 comments

Comments

@Michaelschnabel-DM
Copy link

Michaelschnabel-DM commented Sep 23, 2024

Hi I am using shiva e.g. to convert a Markdown File to a PDF file.
The content of the PDF itself seems to be present, but when opened with any pdf viewer like adobe acrobat it displays only blank pages.
I can even reproduce it with a very simple txt file.


fn prepare_license_pdf_binary(license_file_bytes: Vec<u8>) {
    let md_content = String::from_utf8(license_file_bytes).unwrap();
    let input_bytes = Bytes::from(md_content);
    let document = shiva::markdown::Transformer::parse(&input_bytes).unwrap();
    let output_bytes = shiva::pdf::Transformer::generate(&document)
        .unwrap()
        .to_vec();

    let mut file = File::create("payload/EULA.pdf").unwrap();
    file.write_all(output_bytes.as_slice()).unwrap();
}

I attached the simple text input file and below the resulting PDF.
Test.txt

Test.pdf

Is this a known bug or am i doing something wrong?

@evgenyigumnov
Copy link
Member

works for me

    #[test]
    fn simple_test() {
        let content = std::fs::read("test/data/test.txt").unwrap();
        let md_content = String::from_utf8(content).unwrap();
        let input_bytes = Bytes::from(md_content);
        let document = markdown::Transformer::parse(&input_bytes).unwrap();
        let output_bytes = pdf::Transformer::generate(&document)
            .unwrap()
            .to_vec();

        std::fs::write(
            "test/data/test.pdf",
            output_bytes,
        ).unwrap();
    }
}

https://github.com/igumnoff/shiva/raw/HEAD/lib/test/data/test.txt

https://github.com/igumnoff/shiva/raw/HEAD/lib/test/data/test.pdf

how to reproduce?

@Michaelschnabel-DM
Copy link
Author

Initially the small example test above didnt work either.
Then i noticed that the fonts folder was completely empty.
After deleting it and running the test it properly filled the fonts folder with all the fonts and also the PDF was fine again.
Not sure if I broke anything on my side that caused the fonts to not be downloaded anymore, but now it works again thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants