Wednesday, September 7, 2016

How to unit test PDF creation in .Net

This is a quick recipe to set up in an easy way unit testing for PDF documents in .Net.

The idea, since it wouldn't be possible to verify the layout of a PDF, is to check its text contents.

In order to do so we can use the iTextSharp library. This library enables creating and editing PDF documents. It's commercial but is free for this kind of usage, as long as you don't make it part of a commercial solution.

First of all you should install iTextSharp Nuget package:

PM> Install-Package iTextSharp

Then you can use the following simple method to check if a given text is present in a PDF binary:

1 comment:

  1. Thanks for sharing this wondeful post.
    We have to know the methods you can easy way to Activate YouTube doing If you are facing issues with YouTube, like how to connect YouTube on your TV, mobile or other devices contact us. Google has provided us the enjoyment, and by YouTube activate, you watch here latest videos, songs, or web series, etc.