Exemplo n.º 1
0
        public virtual void TestMergeFields1()
        {
            String f1       = RESOURCES + "copy/pdfa-1a.pdf";
            String f2       = RESOURCES + "copy/pdfa-1a-2.pdf";
            String testName = "testMergeFields1.pdf";

            FileStream outputPdfStream = new FileStream(outputDir + testName, FileMode.Create);
            Document   document        = new Document();
            PdfACopy   copy            = new PdfACopy(document, outputPdfStream, PdfAConformanceLevel.PDF_A_1A);

            copy.SetMergeFields();
            copy.CreateXmpMetadata();
            copy.SetTagged();
            document.Open();
            document.AddLanguage("en-US");
            foreach (String f in new String[] { f1, f2 })
            {
                PdfReader reader = new PdfReader(f);
                copy.AddDocument(reader);
            }

            FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read,
                                                        FileShare.Read);
            ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);

            iccProfileFileStream.Close();

            copy.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
            copy.Close();
        }
Exemplo n.º 2
0
        public virtual void TestMergeFields4()
        {
            String f1 = RESOURCES + "copy/pdfa-1a.pdf";
            String f2 = RESOURCES + "copy/source16.pdf";

            Stream   outputPdfStream = new MemoryStream();
            Document document        = new Document();
            PdfACopy copy            = new PdfACopy(document, outputPdfStream, PdfAConformanceLevel.PDF_A_1B);

            copy.SetMergeFields();
            copy.CreateXmpMetadata();
            copy.SetTagged();
            document.Open();
            document.AddLanguage("en-US");
            bool exceptionThrown = false;

            try {
                foreach (String f in new String[] { f1, f2 })
                {
                    PdfReader reader = new PdfReader(f);
                    copy.AddDocument(reader);
                }
            } catch (PdfAConformanceException e) {
                if (e.Message.Contains("Only PDF/A documents can be added in PdfACopy"))
                {
                    exceptionThrown = true;
                }
            }

            if (!exceptionThrown)
            {
                Assert.Fail("PdfAConformanceException should be thrown.");
            }
        }