The problem you're describing (where something loads the second time you open it but not the first) is almost always a case of something happening asynchronously and the view not updating after the async code has finished. Looking at what you've posted, it looks like the first view controller's table didSelectRow function, configureDocPdf runs asynchronously and the pdf presenting code doesn't wait for it to finish before firing. So the first time you load the PDF, your URLSession is still trying to get the data when LectorPdfViewController is initialized with self.doc (which wouldn't have loaded yet).
Another way to test this would be to try and load different PDFs each time, and see if it's always displaying the previous PDF you tried to load. That would be because the URLSession finished the previous self.doc, but not the one you're trying now.
If that turns out to be the problem, you'll need to hold off loading the pdf view controller and presenting it until after the pdf data is downloaded. In the future, you might also take a look at the new async/await APIs which would prevent a bug like this from happening.
Hope this helps.