-
Notifications
You must be signed in to change notification settings - Fork 273
Description
In trying to test logic related to PDF content building, we ran into issues with regards to verifying content. Additionally, the API for some renderable types don't seem consistent. For instance, the type creator.Paragraph has a public func Text() available to inspect/interrogate the contents of the paragraph. However, If I wanted to inspect the contents of creator.Table, or creator.StyledParagraph, etc, the content related data is private. If possible, it would be wonderful to just have access to say Cells in Table, with further access to each type's content or basic styling.
The main argument for this is to help ease development. If we want to verify we are building up the right datastructures before rendering them/writing them to disk, for instance in a unit test scenario, it would be much easier to simply verify that our logic worked by interrogating these types rather than trying to write an integration style test for each branch of logic we might need. For example, if I had code that should build up a table with different content depending on some boolean logic, the only thing I can inspect is the column count and the row count, I have no way to inspect the cells that were added or further the content in each one. Even if I hold a reference to the cell I use in my test scenario, I still can't get access to it's content.
We can work around some of this by testing content generation before adding it to a cell's content, or by avoiding types like creator.StyledParagraph for instance, but it would be a lot simpler if we just had access to the fields of the type. In some cases our only options are to write the pdf to disk and then do a visual diff, which means we need generated baseline pdf/images for each if statement in our code. The other option we've been exploring is to try to write to memory/disk and then read it in and use the extractor to inspect the tables content or other generated content. This approach is really just an arduous band-aid around the fact that we can't inspect the contents/fields of many of the types we are testing against.
Basically, it would be a huge help to just have a public 'getter' for many of the fields in these types. I know it might take a bit to try and add something like this to everything, so if you are interested in starting with a smaller subset, I could provide a list of types we're actively working with that would help us out immensely.
If I'm not making sense, I'd love to discuss further or show code examples for anything that might not be clear.