I have PDF generation feature in my app. I am using
iTextPDF for generating reports, so it works well. The problem is not exactly in pdf generation but in approach. Currently PDF generation code looks horrible, hard-coded and not flexible, so there is a lot of duplication and everything is highly coupled.
Are there any best or common practices for such a task? Maybe some architectural approach or pattern? I would be very grateful for any advice and code example that was proven as reliable and flexible.