Exemplo n.º 1
0
        public async Task ShouldConvertToPdfA2B(string level, string part, string conformance)
        {
            var path    = $"/pdfa";
            var fixture = $"{Program.TestProjectPath}/Fixtures/dummy.pdf";
            var pdfFile = await File.ReadAllBytesAsync(fixture);

            var formData = new PdfFormData().WithConformanceLevel(level).Upload(pdfFile);
            var response = await _client.PostAsync(path, formData);

            var stream = await response.Content.ReadAsStreamAsync();

            var pdfa             = new PdfADocument(new PdfReader(stream), new PdfWriter(new MemoryStream()));
            var xmpMetadataBytes = pdfa.GetXmpMetadata();
            var xmpMetadata      = XMPMetaFactory.ParseFromBuffer(xmpMetadataBytes);
            var conformanceLevel = PdfAConformanceLevel.GetConformanceLevel(xmpMetadata);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(part, conformanceLevel.GetPart());
            Assert.Equal(conformance, conformanceLevel.GetConformance());
        }