Algorithm for printing all accepted strings (to an upper bound if infinite amount) from a given DFA
The simplest one is to generate all strings up to length n and test them against the DFA.

The next option is a Breadth first traversal over the DFA (emitting the string each time you encounter a final state) however this can need a lot of memory. In the worst case all you need to keep all of length n in memory.

Next is a depth first traversal up to length n. Keep a counter of how long the string would be and backtrack when you exceed n.

To instead get the first n strings you run one of the above algorithms with a certain length and if it generates not enough strings you increment n until it does.