This is what I am doing,
Creating a new Pdf document using Aspose Pdf
Adding few different types pages you know introduction page, table of content pages etc…
Adding some further documents to it [just created pdf].
Not sure which pattern to use.
I am thinking about creating classes for different types of pages to create specific pages, as different departments can ask for different introduction pages or different layout of table of contents and so on…
Page type classes will have a contruct which will create the page and return the pdf component back.
for each different layout i will create a new page.
5
IMHO you are approaching this from the very wrong end. You ask for avoiding duplicate code where it seems you do not have any (or at least not much) code so far.
Better start implementing the code for creating one or two PDFs, and whenever you are tempted to copy/paste a piece of code, stop for moment, step back and think if you can avoid the duplication by refactoring the common parts into a single function. Whenever you have to deal with data forming a group which belongs together, try to introduce a struct
or a class
. And when you note you have isolated operations on that data, refactor to member functions of the created class. When you notice you have similar requirements in different classes, refactor those out to helper classes, common base classes and in the end resusable libraries.
When you follow that path, you may come to a point when you have written real code where you have problems to isolate commonalities – then is a good time to present the problem here, or on stackoverflow.com, or on codereview.stackexchange, and ask if there is a design pattern which can help you.