示例#1
0
        private static async Task MainAsync()
        {
            File.Delete("output.pdf");

            var prizmDocServer = new PrizmDocServerClient(Environment.GetEnvironmentVariable("BASE_URL"), Environment.GetEnvironmentVariable("API_KEY"));

            // Take a DOCX file and replace its cover page with a boilerplate cover,
            // append a boilerplate back page, and then produce a new PDF.
            ConversionResult result = await prizmDocServer.CombineToPdfAsync(
                new[]
            {
                new ConversionSourceDocument("boilerplate-cover-page.pdf"),         // start with a boilerplate cover page
                new ConversionSourceDocument("project-proposal.docx", pages: "2-"), // keep all but the first page of the "main" document
                new ConversionSourceDocument("boilerplate-back-page.pdf"),          // end with a boilerplate back page
            });

            // Save the result to "output.pdf".
            await result.RemoteWorkFile.SaveAsync("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");
        }