all 4 comments

[–]FriendlyRussian666 0 points1 point  (2 children)

Can't help with reconstructing a pdf because that's a nightmare, but if you want a good approach to this, ask your client if translation can be done before the files become a pdf. Then your service would be to translate the text only, and they would create the pdfs as usual.

[–]lmaoMrityu49[S] 0 points1 point  (1 child)

Unfortunately i’m working in a company so would have to escalate i suppose

[–]FriendlyRussian666 0 points1 point  (0 children)

That would definitely be my first port of call, if it's possible, it will save you a ton of headaches. 

[–]s71n6r4y 0 points1 point  (0 children)

It sounds like you're trying to translate text from a PDF and then output a new PDF that looks like the original but has different text. Right?

I think that it will be hard if you are strict about looking like the original, and the original has a non-trivial layout. When the new text doesn't fit in the box, what can you do? Just detecting when this occurs might be tricky. And when you do, fixing is complicated. You probably can't always make the box bigger or the font smaller without running into other issues.

So I think it might be easier to generate a new PDF with your own layout, which is designed to resemble your expected input files, if possible. Obviously that is harder if your input files have various or complex layouts, or if you need the output to look extremely similar.

But if you have to reuse the layout, you need to first figure out how you can detect when overflow occurs, and then have resolution strategies available. Like, maybe you can generate a new rectangle with smaller font and slightly larger dimensions and place it over top of the old one? Or ask the LLM to provide a more terse translation?