Quote:I don't know how to approach this problem
Start by looking at your text file and working out exactly what is in there: how is it organised? What data does it contain?
Work out what separates one "paper format" from another: if all the information for A4 is on one line and all the information for A3 is on another, than that is a simple line based format, which makes it easy to separate data items, and that's the first step.
Once you have worked that out - and remember that no code is needed yet - look at each separate data item, and work out what it contains. If it's just the name of the paper size ("A4" or "A3") than that's trivial - if it's also the actual size ("210mm x 297mm", "297mm x 420mm"), or it also contains margin info for example, then repeat the above for each data item to work out what separates them, what defines "this is the width" from "this is the top margin"?
Work that out, and starting to code to read the file becomes fairly easy. But without it, you - and by extension us - are severely lacking in information to solve this at all!