lopdf icon indicating copy to clipboard operation
lopdf copied to clipboard

modify PDF document example

Open shiftrtech opened this issue 4 years ago • 6 comments

When i use the modify PDF document example:


let mut doc = Document::load("example.pdf")?;
doc.version = "1.4".to_string();
doc.replace_text(1, "Hello World!", "Modified text!");
doc.save("modified.pdf")?;

It doesn't works, i get this text oee on my own PDF document, any help is much apreciated

shiftrtech avatar Nov 28 '20 12:11 shiftrtech

Is a strange behavior, i am using a pdf generated from illustrator (on windows), is there some guides to export de PDF to modify correctly with lopdf or is there some recomended software to create a valid PDF file?

shiftrtech avatar Nov 30 '20 20:11 shiftrtech

Will you upload the example.pdf file for investigation?

J-F-Liu avatar Dec 02 '20 13:12 J-F-Liu

Hey, this is my example , i am trying to use it as a template so i can replace the {variable} texts with my actual value. Its seems the replace its working bu when i visualize the new PDF some charactes doesnt get print

shiftrtech avatar Dec 03 '20 23:12 shiftrtech

Some text is replaced, but the embeded font encoding is not correct for the new chars, try embed the whole font.

After decompress the file, can see this:

/TT0 1 Tf
15 0 0 15 437.4551 471.002 Tm
[({identi)-1.5 (fication_id})]TJ

{identification_id} is split into two operands.

J-F-Liu avatar Dec 04 '20 01:12 J-F-Liu

I did try with multiple fonts and always i get the same error, what did you mean by try embed the whole font?

shiftrtech avatar Dec 04 '20 02:12 shiftrtech

https://publicatorcommunity.zmags.com/hc/en-us/articles/115002482043-Difference-between-full-embedded-fonts-and-embedded-subset

J-F-Liu avatar Dec 04 '20 07:12 J-F-Liu