-
Notifications
You must be signed in to change notification settings - Fork 162
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
Some PDF pages cannot be injected with text objects #2
Comments
Fixed a related bug that broke the pointer system (the library relies heavily on objects sharing memory space. Since stumps were secured and copied, it could cause the pointer system to fail when fonts or images were added more then once. The pointer issue is now fixed, and the injection bug happens less often - but it is still unresolved. |
Resolved. Used a patch to insert a layer of graphics state with default values. It should work fine with any PDF... at least all the PDF's I tested were stamped correctly. |
Hi @boazsegev Thanks |
Hi Đôn Nguyễn, Thank you for opening this issue :-) I tried opening the files and writing text, but it seemed to have worked on my machine... maybe it's something I'm doing different...? or a different version...? Which version are you using? Can you please post an example code that demonstrates the issue? I'm very busy these next two weeks because these are the last two weeks of this semester at my collage, but I hope I will be able to get a look soon and help you solve the issue. Thanks again, |
Please let me know if you still experience the issue. Kindly, |
hi @boazsegev Again, thank you, @boazsegev 👍 |
Btw, below is the code that we used: watermark = "Text here"
pdf.pages.each do |page|
page.textbox "", opacity: 0.7, height: 40, y: 810,
box_color: [1,1,1]
page.textbox watermark, text_valign: :top,
font_size: 8, font_color: [0,0,0], height: 15, y: 822,
text_align: :center
page.textbox "Text here again", text_valign: :top,
font_size: 8, font_color: [0,0,0], height: 15, y: 812,
text_align: :center
end And here is the working code: watermark = "Text here"
pdf.pages.each do |page|
v_position = page.page_size[3]
page.textbox "", opacity: 0.7, height: 40, y: v_position - 28,
box_color: [1,1,1]
page.textbox watermark,
font_size: 8, text_valign: :top, y: v_position - 50
page.textbox "Text here again",
font_size: 8, text_valign: :top, y: v_position - 250
end |
Hi @donnguyen , Thanks for keeping me posted! I think the reason might be that not all PDF files start at Y=0... but the default I think I'll change the default on the next release, to allow for non-zero / cropped page origin points (i.e., pages that start at 10,10). Thanks again and good luck, |
Hi, |
Some PDFs, specifically certain scanned PDF files (usually those with text recognition), cannot be injected with text objects.
The text injected into those PDF pages (I tried numbering the pages) was not rendered - or, as far as I could tell, was rendered as transparent (render mode 3) even when the mode operator (render modes 1 and 2) was present.
Shapes injected into the same pages were rendered correctly.
Seems as if the previous content streams (the ones after which the content is injected) override the later content streams (the injected data).
Reversing the streams order could not be tested, because the white page - although scanned - isn't transparent, so that the content "behind" it could not be observed.
The text was updated successfully, but these errors were encountered: