當前位置: 首頁>>代碼示例>>C#>>正文


C# Document.AddLanguage方法代碼示例

本文整理匯總了C#中iTextSharp.text.Document.AddLanguage方法的典型用法代碼示例。如果您正苦於以下問題:C# Document.AddLanguage方法的具體用法?C# Document.AddLanguage怎麽用?C# Document.AddLanguage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.Document的用法示例。


在下文中一共展示了Document.AddLanguage方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestCreatePdfA_1

        public virtual void TestCreatePdfA_1() {
            String f1 = RESOURCES + "copy\\pdfa-1a.pdf";
            String testName = "testCreatePdfA_1.pdf";

            FileStream outputPdfStream = new FileStream(outputDir + testName, FileMode.Create);
            Document document = new Document();
            PdfACopy copy = new PdfACopy(document, outputPdfStream, PdfAConformanceLevel.PDF_A_1B);
            copy.CreateXmpMetadata();
            document.Open();
            document.AddLanguage("en-US");
            PdfReader reader = new PdfReader(f1);

            PdfImportedPage page = copy.GetImportedPage(reader, 1);
            PdfCopy.PageStamp stamp = copy.CreatePageStamp(page);
            Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 24);
            ColumnText.ShowTextAligned(stamp.GetUnderContent(), Element.ALIGN_CENTER, new Phrase("Hello world!", font), 100, 500, 0);
            stamp.AlterContents();
            copy.AddPage(page);

            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();
        }
開發者ID:yu0410aries,項目名稱:itextsharp,代碼行數:27,代碼來源:PdfACopyTest.cs

示例2: TryCreatePdf

        public bool TryCreatePdf(string nameBank)
        {
            try
            {
                using (FileStream file = new FileStream(String.Format(path,nameBank), FileMode.Create))
                {
                    Document document = new Document(PageSize.A7);
                    PdfWriter writer = PdfWriter.GetInstance(document, file);

                    /// Create metadate pdf file
                    document.AddAuthor("");
                    document.AddLanguage("pl");
                    document.AddSubject("Payment transaction");
                    document.AddTitle("Transaction");
                    /// Create text in pdf file
                    document.Open();
                    document.Add(new Paragraph(_przelew+"\n"));
                    document.Add(new Paragraph(String.Format("Bank {0}: zaprasza\n",nameBank)));
                    document.Add(new Paragraph(DateTime.Now.ToString()));
                    document.Close();
                    writer.Close();
                    file.Close();
                    return true;
                }
            }
            catch (SystemException ex)
            {
                return false;
            }
        }
開發者ID:sparrow41,項目名稱:training,代碼行數:30,代碼來源:PdfCreator.cs

示例3: TestMergeFields1

        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();
        }
開發者ID:Niladri24dutta,項目名稱:itextsharp,代碼行數:26,代碼來源:PdfACopyTest.cs

示例4: Form1

        // From <ClickButt> -> PdfConnector PdfCreatora <- PdfCreator(naemBank,Bodytext)
        // Form <Image> <- PdfConnector -- tworzyć pdf |
        public Form1() 
        {
            while (!fileBanksLists.EndOfStream)
            {
                    InitializeComponent();
            
                     using (FileStream file = new FileStream(String.Format(path, nameBank), FileMode.Create))
                    {

                        Document document = new Document(PageSize.A7);
                        PdfWriter writer = PdfWriter.GetInstance(document, file);
              
                        /// Create metadate pdf file
                        document.AddAuthor(nameBank);
                        document.AddLanguage("pl");
                        document.AddSubject("Payment transaction");
                        document.AddTitle("Transaction");
                        document.AddKeywords("OutcomingNumber :" + OutcomingNumber);
                        document.AddKeywords("IncomingNumber :" + IncomingNumber);
                        /// Create text in pdf file
                        document.Open();
                        document.Add(new Paragraph(_przelew + "\n"));
                        document.Add(new Paragraph(String.Format("Bank {0}: zaprasza\n", nameBank)));
                        document.Add(new Paragraph(DateTime.Now.ToString()));
                        document.Close();
                        writer.Close();
                        file.Close();
                    }
            }
            
            
        }
開發者ID:blacha14,項目名稱:nitrogen,代碼行數:34,代碼來源:Form1.cs

示例5: TestSmartCopyCreatePdfA_1

        public void TestSmartCopyCreatePdfA_1() {
            String fileName = RESOURCES + "copy/pdfa-1a.pdf";
            String testName = "testSmartCopyPdfA_1.pdf";

            FileStream outputPdfStream = File.Create(outputDir + testName);
            Document document = new Document();
            PdfCopy copy = new PdfASmartCopy(document, outputPdfStream, PdfAConformanceLevel.PDF_A_1B);
            copy.CreateXmpMetadata();
            document.Open();
            document.AddLanguage("en-US");
            PdfReader reader = new PdfReader(fileName);
            PdfImportedPage page = copy.GetImportedPage(reader, 1);
            copy.AddPage(page);
            copy.Close();
        }
開發者ID:yu0410aries,項目名稱:itextsharp,代碼行數:15,代碼來源:PdfACopyTest.cs

示例6: TestImportedPage2

        public virtual void TestImportedPage2() {
            String f1 = RESOURCES + "copy/pdfa-1a.pdf";
            String f2 = RESOURCES + "copy/pdfa-1a-2.pdf";
            String f3 = RESOURCES + "copy/pdfa-2a.pdf";

            Stream outputPdfStream = new MemoryStream();
            Document document = new Document();
            PdfACopy copy = new PdfACopy(document, outputPdfStream, PdfAConformanceLevel.PDF_A_1A);
            copy.CreateXmpMetadata();
            copy.SetTagged();
            document.Open();
            document.AddLanguage("en-US");

            bool exceptionThrown = false;
            try {
                foreach (String f in new String[] {f1, f2, f3}) {
                    PdfReader reader = new PdfReader(f);
                    for (int i = 1; i <= reader.NumberOfPages; i++) {
                        copy.AddPage(copy.GetImportedPage(reader, i, true));
                    }
                }
            } catch (PdfAConformanceException e) {
                if (e.Message.Contains("Different PDF/A version"))
                    exceptionThrown = true;
            }

            if (!exceptionThrown)
                Assert.Fail("PdfAConformanceException should be thrown.");
        }
開發者ID:yu0410aries,項目名稱:itextsharp,代碼行數:29,代碼來源:PdfACopyTest.cs

示例7: TestMergeFields4

        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.");
        }
開發者ID:yu0410aries,項目名稱:itextsharp,代碼行數:26,代碼來源:PdfACopyTest.cs

示例8: FromHtml

        public static byte[] FromHtml(string html)
        {
            using (MemoryStream memoryStream = new MemoryStream())
            {
                Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4);
                //PdfAWriter writer = PdfAWriter.GetInstance(document, ms, PdfAConformanceLevel.PDF_A_1B);
                PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
                writer.PdfVersion = PdfWriter.VERSION_1_7;
                writer.SetTagged();
                writer.ViewerPreferences = PdfWriter.DisplayDocTitle;
                writer.CloseStream = false;
                writer.InitialLeading = 12.5f;
                writer.CompressionLevel = PdfStream.BEST_COMPRESSION;
                //writer.SetFullCompression(); //Causa erro no padrão PDF_A_1*

                try
                {
                    document.AddLanguage("pt-BR");
                    document.AddCreationDate();
                    writer.CreateXmpMetadata();
                    document.Open();

                    //FontFactory.RegisteredFonts.Add("");
                    FontFactory.RegisterDirectories();
                    ICC_Profile icc = ICC_Profile.GetInstance((byte[])Properties.Resources.ResourceManager.GetObject("icc_profile"));
                    writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);

                    //MemoryStream cssStream = new MemoryStream(Encoding.UTF8.GetBytes("html, html * { font-family: Arial, Arial, Arial!important; color: black!important; }"));
                    MemoryStream cssStream = new MemoryStream(Encoding.UTF8.GetBytes("body { font-family: \"Courier New\", Courier, monospace!important; color: black!important; }"));
                    MemoryStream htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(html));
                    XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, htmlStream, cssStream);
                    document.Close();
                    writer.Close();
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                return memoryStream.ToArray();
            }
        }
開發者ID:fabiohvp,項目名稱:DocumentSigner,代碼行數:42,代碼來源:PdfHelper.cs

示例9: CreateTagedPdf25

        public virtual void CreateTagedPdf25() {
            Document document = new Document();
            MemoryStream baos = new MemoryStream();

            PdfWriter writer = PdfWriter.GetInstance(document, baos);

            writer.ViewerPreferences = PdfWriter.DisplayDocTitle;

            writer.PdfVersion = PdfWriter.VERSION_1_7;
            writer.SetTagged();
            PdfDictionary info = writer.Info;
            info.Put(PdfName.TITLE, new PdfString("Testing"));
            writer.CreateXmpMetadata();

            document.Open();
            document.AddLanguage("en_US");
            document.SetAccessibleAttribute(PdfName.LANG, new PdfString("en_US"));

            string longParagraphString = "Long teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeext Paragraph testing testing";
            BaseFont bFont = BaseFont.CreateFont(RESOURCES + @"..\FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED);
            Font font = new Font(bFont, 12);
            Paragraph p = new Paragraph(longParagraphString, font);
            document.Add(p);

            string longChunkString = "Long teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeext Span testing testing";
            Chunk ck = new Chunk(longChunkString, font);
            p = new Paragraph(ck);
            document.Add(p);

            document.Close();
            FileStream fos = new FileStream("TaggedPdfTest/pdf/out25.pdf", FileMode.Create);
            byte[] buff = baos.ToArray();
            fos.Write(buff, 0, buff.Length);
            fos.Flush();
            fos.Close();
            CompareResults("25");

            CompareTool compareTool = new CompareTool();
            string cmpFile = RESOURCES + @"out25.pdf";
            string errorMessage = compareTool.CompareByContent("TaggedPdfTest/pdf/out25.pdf", cmpFile,
                "TaggedPdfTest/pdf/", "diff_");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }

        }
開發者ID:newlysoft,項目名稱:itextsharp,代碼行數:46,代碼來源:TaggedPdfTest.cs

示例10: createPdf

        /**
         * Creates an accessible PDF with images and text.
         */
        public void createPdf(String dest)
        {
            Document document = new Document(PageSize.A4.Rotate());
            PdfWriter writer = PdfWriter.GetInstance(document, File.OpenRead(dest));
            writer.PdfVersion = PdfWriter.VERSION_1_7;
            //TAGGED PDF
            //Make document tagged
            writer.SetTagged();
            //===============
            //PDF/UA
            //Set document metadata
            writer.ViewerPreferences = PdfWriter.DisplayDocTitle;
            document.AddLanguage("en-US");
            document.AddTitle("English pangram");
            writer.CreateXmpMetadata();
            //=====================
            document.Open();

            Paragraph p = new Paragraph();
            //PDF/UA
            //Embed font
            Font font = FontFactory.GetFont(FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 20);
            p.Font = font;
            //==================
            Chunk c = new Chunk("The quick brown ");
            p.Add(c);
            Image i = Image.GetInstance(FOX);
            c = new Chunk(i, 0, -24);
            //PDF/UA
            //Set alt text
            c.SetAccessibleAttribute(PdfName.ALT, new PdfString("Fox"));
            //==============
            p.Add(c);
            p.Add(new Chunk(" jumps over the lazy "));
            i = Image.GetInstance(DOG);
            c = new Chunk(i, 0, -24);
            //PDF/UA
            //Set alt text
            c.SetAccessibleAttribute(PdfName.ALT, new PdfString("Dog"));
            //==================
            p.Add(c);
            document.Add(p);

            p = new Paragraph("\n\n\n\n\n\n\n\n\n\n\n\n", font);
            document.Add(p);
            List list = new List(true);
            list.Add(new ListItem("quick", font));
            list.Add(new ListItem("brown", font));
            list.Add(new ListItem("fox", font));
            list.Add(new ListItem("jumps", font));
            list.Add(new ListItem("over", font));
            list.Add(new ListItem("the", font));
            list.Add(new ListItem("lazy", font));
            list.Add(new ListItem("dog", font));
            document.Add(list);
            document.Close();
        }
開發者ID:sensusaps,項目名稱:RoboBraille.Web.API,代碼行數:60,代碼來源:DacChecker.cs


注:本文中的iTextSharp.text.Document.AddLanguage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。