public async Task With_local_file_path()
        {
            PrizmDocServerClient prizmDocServer = Util.CreatePrizmDocServerClient();
            ConversionResult     result         = await prizmDocServer.ConvertToPdfAsync("documents/example.docx");

            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(2, result.PageCount);

            ConversionSourceDocument resultSourceDocument = result.Sources.ToList()[0];

            Assert.IsNotNull(resultSourceDocument.RemoteWorkFile);
            Assert.IsNull(resultSourceDocument.Password);
            Assert.AreEqual("1-2", resultSourceDocument.Pages);

            await result.RemoteWorkFile.SaveAsync("output.pdf");

            FileAssert.IsPdf("output.pdf");
        }
示例#2
0
        public async Task Single_input()
        {
            PrizmDocServerClient prizmDocServer = Util.CreatePrizmDocServerClient();
            ConversionResult     result         = await prizmDocServer.OcrToPdfAsync("documents/ocr/chaucer-scan-3-pages.pdf");

            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(3, result.PageCount);

            ConversionSourceDocument resultSourceDocument = result.Sources.ToList()[0];

            Assert.IsNotNull(resultSourceDocument.RemoteWorkFile);
            Assert.IsNull(resultSourceDocument.Password);
            Assert.AreEqual("1-3", resultSourceDocument.Pages);

            await result.RemoteWorkFile.SaveAsync("output.pdf");

            FileAssert.IsPdf("output.pdf");
        }
        public async Task Just_the_first_page()
        {
            PrizmDocServerClient     prizmDocServer = Util.CreatePrizmDocServerClient();
            ConversionSourceDocument sourceDocument = new ConversionSourceDocument("documents/example.docx", pages: "1");
            ConversionResult         result         = await prizmDocServer.ConvertToPdfAsync(sourceDocument);

            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(1, result.PageCount);

            ConversionSourceDocument resultSourceDocument = result.Sources.ToList()[0];

            Assert.AreEqual(sourceDocument.RemoteWorkFile, resultSourceDocument.RemoteWorkFile);
            Assert.IsNull(resultSourceDocument.Password);
            Assert.AreEqual("1", resultSourceDocument.Pages);

            await result.RemoteWorkFile.SaveAsync("output.pdf");

            FileAssert.IsPdf("output.pdf");
        }
        public async Task Can_perform_a_conversion()
        {
            PrizmDocServerClient prizmDocServer = Util.CreatePrizmDocServerClient();

            IEnumerable <ConversionResult> results = await prizmDocServer.ConvertAsync(
                new List <ConversionSourceDocument>
            {
                new ConversionSourceDocument("documents/example.docx", pages: "1"),
                new ConversionSourceDocument("documents/example.docx"),
            },
                new DestinationOptions(DestinationFileFormat.Pdf));

            Assert.AreEqual(1, results.Count());
            Assert.AreEqual(3, results.Single().PageCount);
            Assert.AreEqual("1", results.Single().Sources.ToList()[0].Pages);
            Assert.AreEqual("1-2", results.Single().Sources.ToList()[1].Pages);

            await results.Single().RemoteWorkFile.SaveAsync("output.pdf");

            FileAssert.IsPdf("output.pdf");
        }
示例#5
0
        private async Task AssertSinglePagePdfResultsAsync(IEnumerable <ConversionResult> results, Action <string> customAssertions = null)
        {
            for (int i = 0; i < results.Count(); i++)
            {
                ConversionResult result = results.ElementAt(i);

                Assert.IsTrue(result.IsSuccess);
                Assert.AreEqual(1, result.PageCount, "Wrong page count for result");

                ConversionSourceDocument resultSourceDocument = result.Sources.ToList()[0];
                Assert.IsNotNull(resultSourceDocument.RemoteWorkFile);
                Assert.IsNull(resultSourceDocument.Password);
                Assert.AreEqual((i + 1).ToString(), resultSourceDocument.Pages, "Wrong source page range for result");

                string filename = $"page-{i}.pdf";
                await result.RemoteWorkFile.SaveAsync(filename);

                FileAssert.IsPdf(filename);

                customAssertions?.Invoke(filename);
            }
        }
示例#6
0
        public async Task Multiple_inputs()
        {
            PrizmDocServerClient prizmDocServer = Util.CreatePrizmDocServerClient();
            var sourceDocument1     = new ConversionSourceDocument("documents/ocr/color.bmp");
            var sourceDocument2     = new ConversionSourceDocument("documents/ocr/text.bmp");
            ConversionResult result = await prizmDocServer.OcrToPdfAsync(new ConversionSourceDocument[] { sourceDocument1, sourceDocument2 });

            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(2, result.PageCount);

            List <ConversionSourceDocument> resultSourceDocuments = result.Sources.ToList();

            Assert.AreEqual(sourceDocument1.RemoteWorkFile, resultSourceDocuments[0].RemoteWorkFile);
            Assert.IsNull(resultSourceDocuments[0].Password);
            Assert.AreEqual("1", resultSourceDocuments[0].Pages);

            Assert.AreEqual(sourceDocument2.RemoteWorkFile, resultSourceDocuments[1].RemoteWorkFile);
            Assert.IsNull(resultSourceDocuments[1].Password);
            Assert.AreEqual("1", resultSourceDocuments[1].Pages);

            await result.RemoteWorkFile.SaveAsync("output.pdf");

            FileAssert.IsPdf("output.pdf");
        }
        public async Task Multiple_inputs_one_with_password()
        {
            PrizmDocServerClient     prizmDocServer  = Util.CreatePrizmDocServerClient();
            ConversionSourceDocument sourceDocument1 = new ConversionSourceDocument("documents/example.docx");
            ConversionSourceDocument sourceDocument2 = new ConversionSourceDocument("documents/password.docx", password: "******");
            ConversionResult         result          = await prizmDocServer.CombineToPdfAsync(new[] { sourceDocument1, sourceDocument2 });

            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(3, result.PageCount);

            List <ConversionSourceDocument> resultSourceDocuments = result.Sources.ToList();

            Assert.AreEqual(sourceDocument1.RemoteWorkFile, resultSourceDocuments[0].RemoteWorkFile);
            Assert.IsNull(resultSourceDocuments[0].Password);
            Assert.AreEqual("1-2", resultSourceDocuments[0].Pages);

            Assert.AreEqual(sourceDocument2.RemoteWorkFile, resultSourceDocuments[1].RemoteWorkFile);
            Assert.IsNull(resultSourceDocuments[1].Password);
            Assert.AreEqual("1", resultSourceDocuments[1].Pages);

            await result.RemoteWorkFile.SaveAsync("output.pdf");

            FileAssert.IsPdf("output.pdf");
        }