indexmap-rs / indexmap

A hash table with consistent order and fast iteration; access items by key or sequence index
https://docs.rs/indexmap/
Other
1.68k stars 150 forks source link

`replace_text` fails every time with `Could not parse ToUnicodeCMap: Error!` #351

Open axoking opened 2 hours ago

axoking commented 2 hours ago

The replace_text function of the Document struct is not working.

Example code:

use lopdf::Document;

fn main() {
    let mut doc = Document::load("document.pdf").unwrap();

    if let Err(error) = doc.replace_text(1, "Hello World", "Goodbye world") {
        println!("{error}");
    }

    doc.save("modified.pdf").unwrap();
}

Gives the following output:

ToUnicode CMap error: Could not parse ToUnicodeCMap: Error!

Happens even with a simple PDF document created by libre office (see below): document.pdf document.odt

cuviper commented 1 hour ago

This is not directly using indexmap -- perhaps you meant to file an issue on lopdf? https://github.com/J-F-Liu/lopdf