public void Verify(FileInfo pdf) { if (!pdf.Exists) { throw new InvalidOperationException("File to verify does not exist '{0}'".Fmt(pdf.FullName)); } using (var destination = new DisposableFile()) { GhostscriptWrapper.GenerateOutput( inputPath: pdf.FullName, outputPath: destination.File.FullName, settings: new GhostscriptSettings { Device = GhostscriptDevices.tiff24nc, Resolution = new Size(72, 72), Size = new GhostscriptPageSize { Native = GhostscriptPageSizes.letter } }); //GhostScript embeds a creation timestamp on each page of the tiff. Obviously if its different every time the files won't match up byte for byte. So normalize using (var tiff = Tiff.Open(destination.File.FullName, "a")) { Enumerable.Range(0, tiff.NumberOfDirectories()).ForEach(i => { tiff.SetDirectory((short)i); tiff.SetField(TiffTag.DATETIME, Encoding.UTF8.GetBytes("2010:01:01 12:00:00")); //any constant date will do the trick here. tiff.CheckpointDirectory(); }); } Approvals.Verify(GetTiffApprovalWriter(destination.File), GetNamer(), GetReporter()); } }
public void Verify(Stream pdf) { using (var pdfFile = new DisposableFile(pdf)) Verify(pdfFile.File); }