• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# pdf.PdfLayer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中iTextSharp.text.pdf.PdfLayer的典型用法代码示例。如果您正苦于以下问题:C# PdfLayer类的具体用法?C# PdfLayer怎么用?C# PdfLayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PdfLayer类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfLayer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetOCGOrder

 private static void GetOCGOrder(PdfArray order, PdfLayer layer) {
     if (!layer.OnPanel)
         return;
     if (layer.Title == null)
         order.Add(layer.Ref);
     List<PdfLayer> children = layer.Children;
     if (children == null)
         return;
     PdfArray kids = new PdfArray();
     if (layer.Title != null)
         kids.Add(new PdfString(layer.Title, PdfObject.TEXT_UNICODE));
     for (int k = 0; k < children.Count; ++k) {
         GetOCGOrder(kids, children[k]);
     }
     if (kids.Size > 0)
         order.Add(kids);
 }
开发者ID:,项目名称:,代码行数:17,代码来源:


示例2: CreatePdf

 // ---------------------------------------------------------------------------
 public byte[] CreatePdf(bool on)
 {
     using (MemoryStream ms = new MemoryStream()) {
     using (Document document = new Document()) {
       // step 2
       PdfWriter writer = PdfWriter.GetInstance(document, ms);
       writer.ViewerPreferences = PdfWriter.PageModeUseOC;
       writer.PdfVersion = PdfWriter.VERSION_1_5;
       // step 3
       document.Open();
       // step 4
       PdfLayer layer = new PdfLayer("Do you see me?", writer);
       layer.On = on;
       BaseFont bf = BaseFont.CreateFont();
       PdfContentByte cb = writer.DirectContent;
       cb.BeginText();
       cb.SetFontAndSize(bf, 18);
       cb.ShowTextAligned(Element.ALIGN_LEFT, "Do you see me?", 50, 790, 0);
       cb.BeginLayer(layer);
       cb.ShowTextAligned(Element.ALIGN_LEFT, "Peek-a-Boo!!!", 50, 766, 0);
       cb.EndLayer();
       cb.EndText();
     }
     return ms.ToArray();
       }
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:27,代码来源:PeekABoo.cs


示例3: CreateTitle

 /**
 * Creates a title layer. A title layer is not really a layer but a collection of layers
 * under the same title heading.
 * @param title the title text
 * @param writer the <CODE>PdfWriter</CODE>
 * @return the title layer
 */    
 public static PdfLayer CreateTitle(String title, PdfWriter writer) {
     if (title == null)
         throw new ArgumentNullException(MessageLocalization.GetComposedMessage("title.cannot.be.null"));
     PdfLayer layer = new PdfLayer(title);
     writer.RegisterLayer(layer);
     return layer;
 }
开发者ID:pusp,项目名称:o2platform,代码行数:14,代码来源:PdfLayer.cs


示例4: ApplyWaterMark

 private static void ApplyWaterMark(string filePath)
 {
     Logger.LogI("ApplyWatermark -> " + filePath);
     var watermarkedFile = Path.GetFileNameWithoutExtension(filePath) + "-w.pdf";
     using (var reader1 = new PdfReader(filePath))
     {
         using (var fs = new FileStream(watermarkedFile, FileMode.Create, FileAccess.Write, FileShare.None))
         using (var stamper = new PdfStamper(reader1, fs))
         {
             var pageCount = reader1.NumberOfPages;
             var layer = new PdfLayer("WatermarkLayer", stamper.Writer);
             for (var i = 1; i <= pageCount; i++)
             {
                 var rect = reader1.GetPageSize(i);
                 var cb = stamper.GetUnderContent(i);
                 cb.BeginLayer(layer);
                 cb.SetFontAndSize(BaseFont.CreateFont(
                     BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), 50);
                 var gState = new PdfGState {FillOpacity = 0.25f};
                 cb.SetGState(gState);
                 cb.SetColorFill(BaseColor.BLACK);
                 cb.BeginText();
                 cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER,
                     "(c)2015 ScrapEra", rect.Width/2, rect.Height/2, 45f);
                 cb.EndText();
                 cb.EndLayer();
             }
         }
     }
     File.Delete(filePath);
 }
开发者ID:abhimanbhau,项目名称:ScrapEra,代码行数:31,代码来源:PdfGenerator.cs


示例5: Write

        // ===========================================================================
        public void Write(Stream stream)
        {
            // step 1
              using (Document document = new Document()) {
            // step 2
            PdfWriter writer = PdfWriter.GetInstance(document, stream);
            writer.PdfVersion = PdfWriter.VERSION_1_6;
            // step 3
            document.Open();
            // step 4
            PdfContentByte cb = writer.DirectContent;

            PdfLayer dog = new PdfLayer("layer 1", writer);
            PdfLayer tiger = new PdfLayer("layer 2", writer);
            PdfLayer lion = new PdfLayer("layer 3", writer);
            PdfLayerMembership cat = new PdfLayerMembership(writer);
            PdfVisibilityExpression ve1 = new PdfVisibilityExpression(
              PdfVisibilityExpression.OR
            );
            ve1.Add(tiger);
            ve1.Add(lion);
            cat.VisibilityExpression = ve1;
            PdfLayerMembership no_cat = new PdfLayerMembership(writer);
            PdfVisibilityExpression ve2 = new PdfVisibilityExpression(
              PdfVisibilityExpression.NOT
            );
            ve2.Add(ve1);
            no_cat.VisibilityExpression = ve2;
            cb.BeginLayer(dog);
            ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("dog"),
                50, 775, 0);
            cb.EndLayer();
            cb.BeginLayer(tiger);
            ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("tiger"),
                50, 750, 0);
            cb.EndLayer();
            cb.BeginLayer(lion);
            ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("lion"),
                50, 725, 0);
            cb.EndLayer();
            cb.BeginLayer(cat);
            ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("cat"),
                50, 700, 0);
            cb.EndLayer();
            cb.BeginLayer(no_cat);
            ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
                new Phrase("no cat"), 50, 700, 0);
            cb.EndLayer();
              }
        }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:51,代码来源:LayerMembershipExample2.cs


示例6: LayerCheckTest1

 public void LayerCheckTest1()
 {
     string filename = OUT + "LayerCheckTest1.pdf";
     FileStream fos = new FileStream(filename, FileMode.Create);
     Document document = new Document();
     PdfWriter writer = PdfAWriter.GetInstance(document, fos, PdfAConformanceLevel.PDF_A_2B);
     writer.ViewerPreferences = PdfWriter.PageModeUseOC;
     writer.PdfVersion = PdfWriter.VERSION_1_5;
     document.Open();
     PdfLayer layer = new PdfLayer("Do you see me?", writer);
     layer.On = true;
     BaseFont bf = BaseFont.CreateFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, true);
     PdfContentByte cb = writer.DirectContent;
     cb.BeginText();
     cb.SetFontAndSize(bf, 18);
     cb.ShowTextAligned(Element.ALIGN_LEFT, "Do you see me?", 50, 790, 0);
     cb.BeginLayer(layer);
     cb.ShowTextAligned(Element.ALIGN_LEFT, "Peek-a-Boo!!!", 50, 766, 0);
     cb.EndLayer();
     cb.EndText();
     document.Close();
 }
开发者ID:,项目名称:,代码行数:22,代码来源:


示例7: AddChild

 /**
 * Adds a child layer. Nested layers can only have one parent.
 * @param child the child layer
 */    
 public void AddChild(PdfLayer child) {
     if (child.parent != null)
         throw new ArgumentException(MessageLocalization.GetComposedMessage("the.layer.1.already.has.a.parent", ((PdfString)child.Get(PdfName.NAME)).ToUnicodeString()));
     child.parent = this;
     if (children == null)
         children = new ArrayList();
     children.Add(child);
 }
开发者ID:pusp,项目名称:o2platform,代码行数:12,代码来源:PdfLayer.cs


示例8: LayerCheckTest2

        public void LayerCheckTest2() {
            string filename = OUT + "LayerCheckTest2.pdf";
            FileStream fos = new FileStream(filename, FileMode.Create);
            Document document = new Document();
            PdfWriter writer = PdfAWriter.GetInstance(document, fos, PdfAConformanceLevel.PDF_A_2B);
            writer.CreateXmpMetadata();
            writer.ViewerPreferences = PdfWriter.PageModeUseOC;
            writer.PdfVersion = PdfWriter.VERSION_1_5;
            document.Open();
            PdfContentByte cb = writer.DirectContent;
            PdfLayer nested = new PdfLayer("Nested layers", writer);
            PdfLayer nested_1 = new PdfLayer("Nested layer 1", writer);
            PdfLayer nested_2 = new PdfLayer("Nested layer 2", writer);
            nested.AddChild(nested_1);
            nested.AddChild(nested_2);
            writer.LockLayer(nested_2);
            cb.BeginLayer(nested);

            Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, true);
            ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("nested layers", font), 50, 775, 0);
            cb.EndLayer();
            cb.BeginLayer(nested_1);
            ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("nested layer 1", font), 100, 800, 0);
            cb.EndLayer();
            cb.BeginLayer(nested_2);
            ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase("nested layer 2", font), 100, 750, 0);
            cb.EndLayer();

            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();

            writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
            document.Close();
        }
开发者ID:smartleos,项目名称:itextsharp,代码行数:35,代码来源:PdfA2CheckerTest.cs


示例9: LayerCheckTest1

        public void LayerCheckTest1() {
            string filename = OUT + "LayerCheckTest1.pdf";
            FileStream fos = new FileStream(filename, FileMode.Create);
            Document document = new Document();
            PdfWriter writer = PdfAWriter.GetInstance(document, fos, PdfAConformanceLevel.PDF_A_2B);
            writer.CreateXmpMetadata();
            writer.ViewerPreferences = PdfWriter.PageModeUseOC;
            writer.PdfVersion = PdfWriter.VERSION_1_5;
            document.Open();
            PdfLayer layer = new PdfLayer("Do you see me?", writer);
            layer.On = true;
            BaseFont bf = BaseFont.CreateFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, true);
            PdfContentByte cb = writer.DirectContent;
            cb.BeginText();
            cb.SetFontAndSize(bf, 18);
            cb.ShowTextAligned(Element.ALIGN_LEFT, "Do you see me?", 50, 790, 0);
            cb.BeginLayer(layer);
            cb.ShowTextAligned(Element.ALIGN_LEFT, "Peek-a-Boo!!!", 50, 766, 0);
            cb.EndLayer();
            cb.EndText();

            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();

            writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
            document.Close();
        }
开发者ID:smartleos,项目名称:itextsharp,代码行数:28,代码来源:PdfA2CheckerTest.cs


示例10: LayerStampingTest

        public void LayerStampingTest() {
            String outPdf = DestFolder + "out3.pdf";
            PdfReader reader =
                new PdfReader(TestResourceUtils.GetResourceAsStream(TestResourcesPath, "House_Plan_Final.pdf"));
            PdfStamper stamper = new PdfStamper(reader, File.Create(outPdf));

            PdfLayer logoLayer = new PdfLayer("Logos", stamper.Writer);
            PdfContentByte cb = stamper.GetUnderContent(1);
            cb.BeginLayer(logoLayer);

            Image iImage = Image.GetInstance(TestResourceUtils.GetResourceAsStream(TestResourcesPath, "Willi-1.jpg"));
            iImage.ScalePercent(24f);
            iImage.SetAbsolutePosition(100, 100);
            cb.AddImage(iImage);

            cb.EndLayer();
            stamper.Close();

            Assert.Null(new CompareTool().CompareByContent(outPdf, TestResourceUtils.GetResourceAsTempFile(TestResourcesPath, "cmp_House_Plan_Final.pdf"), DestFolder, "diff_"));
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:20,代码来源:PdfStamperTest.cs


示例11: Write

        // ===========================================================================
        public void Write(Stream stream)
        {
            // step 1
              using (Document document = new Document()) {
            // step 2
            PdfWriter writer = PdfWriter.GetInstance(document, stream);
            writer.PdfVersion = PdfWriter.VERSION_1_5;
            // step 3
            document.Open();
            // step 4
            PdfLayer a1 = new PdfLayer("answer 1", writer);
            PdfLayer a2 = new PdfLayer("answer 2", writer);
            PdfLayer a3 = new PdfLayer("answer 3", writer);
            a1.On = false;
            a2.On = false;
            a3.On = false;

            BaseFont bf = BaseFont.CreateFont();
            PdfContentByte cb = writer.DirectContent;
            cb.BeginText();
            cb.SetFontAndSize(bf, 18);
            cb.ShowTextAligned(Element.ALIGN_LEFT,
            "Q1: Who is the director of the movie 'Paths of Glory'?", 50, 766, 0);
            cb.ShowTextAligned(Element.ALIGN_LEFT,
            "Q2: Who directed the movie 'Lawrence of Arabia'?", 50, 718, 0);
            cb.ShowTextAligned(Element.ALIGN_LEFT,
            "Q3: Who is the director of 'House of Flying Daggers'?", 50, 670, 0);
            cb.EndText();
            cb.SaveState();
            cb.SetRGBColorFill(0xFF, 0x00, 0x00);
            cb.BeginText();
            cb.BeginLayer(a1);
            cb.ShowTextAligned(Element.ALIGN_LEFT,
                "A1: Stanley Kubrick", 50, 742, 0);
            cb.EndLayer();
            cb.BeginLayer(a2);
            cb.ShowTextAligned(Element.ALIGN_LEFT,
                "A2: David Lean", 50, 694, 0);
            cb.EndLayer();
            cb.BeginLayer(a3);
            cb.ShowTextAligned(Element.ALIGN_LEFT,
                "A3: Zhang Yimou", 50, 646, 0);
            cb.EndLayer();
            cb.EndText();
            cb.RestoreState();

            List<Object> stateOn = new List<Object>();
            stateOn.Add("ON");
            stateOn.Add(a1);
            stateOn.Add(a2);
            stateOn.Add(a3);
            PdfAction actionOn = PdfAction.SetOCGstate(stateOn, true);
            List<Object> stateOff = new List<Object>();
            stateOff.Add("OFF");
            stateOff.Add(a1);
            stateOff.Add(a2);
            stateOff.Add(a3);
            PdfAction actionOff = PdfAction.SetOCGstate(stateOff, true);
            List<Object> stateToggle = new List<Object>();
            stateToggle.Add("Toggle");
            stateToggle.Add(a1);
            stateToggle.Add(a2);
            stateToggle.Add(a3);
            PdfAction actionToggle = PdfAction.SetOCGstate(stateToggle, true);
            Phrase p = new Phrase("Change the state of the answers:");
            Chunk on = new Chunk(" on ").SetAction(actionOn);
            p.Add(on);
            Chunk off = new Chunk("/ off ").SetAction(actionOff);
            p.Add(off);
            Chunk toggle = new Chunk("/ toggle").SetAction(actionToggle);
            p.Add(toggle);
            document.Add(p);
              }
        }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:75,代码来源:OptionalContentActionExample.cs


示例12: LockLayer

 /**
 * Use this method to lock an optional content group.
 * The state of a locked group cannot be changed through the user interface
 * of a viewer application. Producers can use this entry to prevent the visibility
 * of content that depends on these groups from being changed by users.
 * @param layer the layer that needs to be added to the array of locked OCGs
 * @since   2.1.2
 */    
 public void LockLayer(PdfLayer layer) {
     OCGLocked.Add(layer.Ref);
 }
开发者ID:,项目名称:,代码行数:11,代码来源:


示例13: ReadOCProperties

 /**
 * Reads the OCProperties dictionary from the catalog of the existing document
 * and fills the documentOCG, documentOCGorder and OCGRadioGroup variables in PdfWriter.
 * Note that the original OCProperties of the existing document can contain more information.
 * @since    2.1.2
 */
 virtual protected void ReadOCProperties() {
     if (documentOCG.Count != 0) {
         return;
     }
     PdfDictionary dict = reader.Catalog.GetAsDict(PdfName.OCPROPERTIES);
     if (dict == null) {
         return;
     }
     PdfArray ocgs = dict.GetAsArray(PdfName.OCGS);
     PdfIndirectReference refi;
     PdfLayer layer;
     Dictionary<string,PdfLayer> ocgmap = new Dictionary<string,PdfLayer>();
     for (ListIterator<PdfObject> i = ocgs.GetListIterator(); i.HasNext();) {
         refi = (PdfIndirectReference)i.Next();
         layer = new PdfLayer(null);
         layer.Ref = refi;
         layer.OnPanel = false;
         layer.Merge((PdfDictionary)PdfReader.GetPdfObject(refi));
         ocgmap[refi.ToString()] = layer;
     }
     PdfDictionary d = dict.GetAsDict(PdfName.D);
     PdfArray off = d.GetAsArray(PdfName.OFF);
     if (off != null) {
         for (ListIterator<PdfObject> i = off.GetListIterator(); i.HasNext(); ) {
             refi = (PdfIndirectReference)i.Next();
             layer = ocgmap[refi.ToString()];
             layer.On = false;
         }
     }
     PdfArray order = d.GetAsArray(PdfName.ORDER);
     if (order != null) {
         AddOrder(null, order, ocgmap);
     }
     foreach (PdfLayer o in ocgmap.Values)
         documentOCG[o] = null;
     OCGRadioGroup = d.GetAsArray(PdfName.RBGROUPS);
     if (OCGRadioGroup == null)
         OCGRadioGroup = new PdfArray();
     OCGLocked = d.GetAsArray(PdfName.LOCKED);
     if (OCGLocked == null)
         OCGLocked = new PdfArray();
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:48,代码来源:PdfStamperImp.cs


示例14: helper_PageEnd

        /// <summary>
        /// Event handler when the end of the page is reached
        /// </summary>
        void helper_PageEnd(object sender, PageEndEventArgs e)
        {
            writer.ViewerPreferences = PdfWriter.PageModeUseOC;
            writer.PdfVersion = PdfWriter.VERSION_1_5;
            PdfLayer layer = new PdfLayer("Pages", writer);
            layer.On = false;
            layer.PageElement = "HF";
            layer.OnPanel = false;
            layer.View = true;
            under.BeginLayer(layer);

            var th = new PdfStructureElement(root, PdfName.ARTIFACT);
            th.Put(PdfName.TYPE, new PdfNull());
            under.BeginMarkedContentSequence(th);

            under.SaveState();
            float bottom = .625f;
            float textBase = document.Bottom - bottom.ToPts();
            float textSize = 12;
            under.BeginText();
            under.SetFontAndSize(GrantFonts.bf_times, textSize);
            float adjust = GrantFonts.bf_times.GetWidthPoint("0", textSize);
            it.Rectangle pSize = document.PageSize;
            float width = pSize.Width / 2;
            under.SetTextMatrix(width - textSize - adjust, textBase);
            under.ShowText(e.page);
            under.EndText();
            under.RestoreState();
            under.EndMarkedContentSequence();

            under.EndLayer();

        }
开发者ID:aracen74,项目名称:Cerritosoft.Pdf.Test,代码行数:36,代码来源:Factory.cs


示例15: ResetBackgroundColor

        public static void ResetBackgroundColor(string originalFile, string watermarked, string color)
        {
            int page = 1;

              PdfReader reader = new PdfReader(originalFile);
              using (FileStream fs = new FileStream(watermarked, FileMode.Create, FileAccess.Write, FileShare.None))
              using (PdfStamper stamper = new PdfStamper(reader, fs))
              {
            PdfLayer layer = new PdfLayer("BackgroundColor", stamper.Writer);

            Rectangle rect = reader.GetPageSize(page);
            PdfContentByte cb = stamper.GetOverContent(page);

            cb.BeginLayer(layer);

            // set color
            CMYKColor chosenColor;
            CMYKColor green = new CMYKColor(0.0809f, 0f, 0.1915f, 0.0784f); //TO DO: get green color

            // set template color
            if (color.Equals("yellow", StringComparison.OrdinalIgnoreCase))
            {
              chosenColor = new CMYKColor(0f, 0.2092f, 0.7741f, 0.0627f);
            }
            else if (color.Equals("red", StringComparison.OrdinalIgnoreCase))
            {
              chosenColor = new CMYKColor(0f, 0.7564f, 0.7372f, 0.3882f);
            }
            else if (color.Equals("purple", StringComparison.OrdinalIgnoreCase))
            {
              chosenColor = new CMYKColor(0.5118f, 0.6693f, 0f, 0.5020f);
            }
            else
            {
              chosenColor = new CMYKColor(0f, 0f, 0f, 0f);
            }

            cb.SetColorFill(chosenColor);
            cb.SetColorStroke(chosenColor);

            // draw name label
            double widthDiff = 23;
            double startHeight = rect.Height - 3;
            double midHeight = rect.Height - 18;
            double endHeight = rect.Height - 27;
            double startWidth = rect.Width * 1 / 3;
            double firstMidWidth = startWidth + widthDiff;
            double endWidth = rect.Width;
            double secondMidWidth = endWidth - widthDiff;

            cb.MoveTo(rect.Width * 1 / 3, startHeight);
            cb.LineTo(rect.Width, startHeight);
            cb.LineTo(rect.Width, midHeight);
            cb.CurveTo(secondMidWidth + (endWidth - secondMidWidth) / 1.4, endHeight + (midHeight - endHeight) / 4, secondMidWidth, endHeight);
            cb.LineTo(firstMidWidth, endHeight);
            cb.CurveTo(firstMidWidth - (firstMidWidth - startWidth) / 1.4, endHeight + (midHeight - endHeight) / 4, startWidth, midHeight);
            cb.ClosePathFillStroke();

            // reset flag
            cb.SetColorFill(green);
            cb.SetColorStroke(green);

            startHeight = endHeight - 0.5;
            double heightDiff = 8.5;
            widthDiff = 13;

            cb.MoveTo(endWidth - widthDiff, startHeight);
            cb.LineTo(endWidth, startHeight);
            cb.LineTo(endWidth, startHeight - heightDiff);
            cb.LineTo(endWidth - widthDiff, startHeight - heightDiff);
            cb.ClosePathFillStroke();

            startHeight = startHeight - heightDiff - 2;
            cb.MoveTo(endWidth - widthDiff, startHeight);
            cb.LineTo(endWidth, startHeight);
            cb.LineTo(endWidth, startHeight - heightDiff);
            cb.LineTo(endWidth - widthDiff, startHeight - heightDiff);
            cb.ClosePathFillStroke();

            startHeight = startHeight - heightDiff - 2;
            cb.MoveTo(endWidth - widthDiff, startHeight);
            cb.LineTo(endWidth, startHeight);
            cb.LineTo(endWidth, startHeight - heightDiff);
            cb.LineTo(endWidth - widthDiff, startHeight - heightDiff);
            cb.ClosePathFillStroke();

            double mealLabelStartHeight = rect.Height - 30;
            double mealLabelHeight = 8;
            double mealLabelStartWidth = rect.Width / 3;
            double mealLabelWidth = 120;

            cb.MoveTo(mealLabelStartWidth, mealLabelStartHeight);
            cb.LineTo(mealLabelStartWidth + mealLabelWidth, mealLabelStartHeight);
            cb.LineTo(mealLabelStartWidth + mealLabelWidth, mealLabelStartHeight - mealLabelHeight);
            cb.LineTo(mealLabelStartWidth, mealLabelStartHeight - mealLabelHeight);
            cb.ClosePathFillStroke();

            double macrosStartHeight = rect.Height - 55;
            double macrosStartWidth = rect.Width / 3 + 5;
            double macrosWidth = 20;
//.........这里部分代码省略.........
开发者ID:yxlee61,项目名称:RecipeManager,代码行数:101,代码来源:PdfHelper.cs


示例16: Watermark

        public static void Watermark(string originalFile, string watermarked)
        {
            int page = 1;

              PdfReader reader = new PdfReader(originalFile);
              using (FileStream fs = new FileStream(watermarked, FileMode.Create, FileAccess.Write, FileShare.None))
              using (PdfStamper stamper = new PdfStamper(reader, fs))
              {
            PdfLayer layer = new PdfLayer("Text", stamper.Writer);

            Rectangle rect = reader.GetPageSize(page);
            PdfContentByte cb = stamper.GetOverContent(page);

            cb.EndLayer();
              }
        }
开发者ID:yxlee61,项目名称:RecipeManager,代码行数:16,代码来源:PdfHelper.cs


示例17: ResetMacrosDetails

        public static void ResetMacrosDetails(string originalFile, string watermarked)
        {
            int page = 1;

              PdfReader reader = new PdfReader(originalFile);
              using (FileStream fs = new FileStream(watermarked, FileMode.Create, FileAccess.Write, FileShare.None))
              using (PdfStamper stamper = new PdfStamper(reader, fs))
              {
            PdfLayer layer = new PdfLayer("Text", stamper.Writer);

            Rectangle rect = reader.GetPageSize(page);
            PdfContentByte cb = stamper.GetOverContent(page);

            CMYKColor color = new CMYKColor(0f, 0f, 0f, 0f);
            cb.SetColorFill(color);
            cb.SetColorStroke(color);

            cb.BeginLayer(layer);

            double startHeight = rect.Height - 85;
            double height = 48;

            cb.MoveTo(0, startHeight);
            cb.LineTo(rect.Width, startHeight);
            cb.LineTo(rect.Width, startHeight - height);
            cb.LineTo(0, startHeight - height);
            cb.ClosePathFillStroke();

            startHeight = rect.Height - 143;
            double startWidth = rect.Width - 85;

            cb.MoveTo(startWidth, startHeight);
            cb.LineTo(rect.Width, startHeight);
            cb.LineTo(rect.Width, startHeight - height);
            cb.LineTo(startWidth, startHeight - height);
            cb.ClosePathFillStroke();

            startHeight = rect.Height - 150;
            double width = 65;
            height = 7;
            startWidth = 5;
            cb.MoveTo(startWidth, startHeight);
            cb.LineTo(startWidth + width, startHeight);
            cb.LineTo(startWidth + width, startHeight - height);
            cb.LineTo(startWidth, startHeight - height);
            cb.ClosePathFillStroke();

            startHeight = rect.Height - 179.5;
            height = 3;
            width = 4;
            startWidth = 115;

            for (int i = 0; i < 7; i++)
            {
              cb.MoveTo(startWidth, startHeight);
              cb.LineTo(startWidth + width, startHeight);
              cb.LineTo(startWidth + width, startHeight - height);
              cb.LineTo(startWidth, startHeight - height);
              cb.ClosePathFillStroke();

              startHeight = startHeight - 5.5;
            }

            startHeight = startHeight - 13;
            height = 2.7;

            for (int i = 0; i < 4; i++)
            {
              cb.MoveTo(startWidth, startHeight);
              cb.LineTo(startWidth + width, startHeight);
              cb.LineTo(startWidth + width, startHeight - height);
              cb.LineTo(startWidth, startHeight - height);
              cb.ClosePathFillStroke();

              startHeight = startHeight - 5.5;
            }

            cb.EndLayer();
              }
        }
开发者ID:yxlee61,项目名称:RecipeManager,代码行数:80,代码来源:PdfHelper.cs


示例18: ResetMacros

        public static void ResetMacros(string originalFile, string watermarked)
        {
            int page = 1;

              PdfReader reader = new PdfReader(originalFile);
              using (FileStream fs = new FileStream(watermarked, FileMode.Create, FileAccess.Write, FileShare.None))
              using (PdfStamper stamper = new PdfStamper(reader, fs))
              {
            PdfLayer layer = new PdfLayer("Text", stamper.Writer);

            Rectangle rect = reader.GetPageSize(page);
            PdfContentByte cb = stamper.GetOverContent(page);

            CMYKColor color = new CMYKColor(0f, 0f, 0f, 0f);
            cb.SetColorFill(color);
            cb.SetColorStroke(color);

            cb.BeginLayer(layer);

            double mealLabelStartHeight = rect.Height - 30;
            double mealLabelHeight = 8;
            double mealLabelStartWidth = rect.Width / 3;
            double mealLabelWidth = 120;

            cb.MoveTo(mealLabelStartWidth, mealLabelStartHeight);
            cb.LineTo(mealLabelStartWidth + mealLabelWidth, mealLabelStartHeight);
            cb.LineTo(mealLabelStartWidth + mealLabelWidth, mealLabelStartHeight - mealLabelHeight);
            cb.LineTo(mealLabelStartWidth, mealLabelStartHeight - mealLabelHeight);
            cb.ClosePathFillStroke();

            double macrosStartHeight = rect.Height - 55;
            double macrosStartWidth = rect.Width / 3 + 5;
            double macrosWidth = 20;
            double macrosHeight = 10;

            for (int i = 0; i < 4; i++)
            {
              cb.MoveTo(macrosStartWidth, macrosStartHeight);
              cb.LineTo(macrosStartWidth + macrosWidth, macrosStartHeight);
              cb.LineTo(macrosStartWidth + macrosWidth, macrosStartHeight - macrosHeight);
              cb.LineTo(macrosStartWidth, macrosStartHeight - macrosHeight);
              cb.ClosePathFillStroke();

              macrosStartWidth = macrosStartWidth + macrosWidth + 13;
            }
            // Close the layer
            cb.EndLayer();
              }
        }
开发者ID:yxlee61,项目名称:RecipeManager,代码行数:49,代码来源:PdfHelper.cs


示例19: Write

// ===========================================================================
    public void Write(Stream stream) {
      // step 1
      using (Document document = new Document()) {
        // step 2
        PdfWriter writer = PdfWriter.GetInstance(document, stream);
        writer.PdfVersion = PdfWriter.VERSION_1_5;
        // step 3
        document.Open();
        // step 4
        PdfContentByte cb = writer.DirectContent;
        PdfLayer nested = new PdfLayer("Nested layers", writer);
        PdfLayer nested_1 = new PdfLayer("Nested layer 1", writer);
        PdfLayer nested_2 = new PdfLayer("Nested layer 2", writer);
        nested.AddChild(nested_1);
        nested.AddChild(nested_2);
        writer.LockLayer(nested_2);
        cb.BeginLayer(nested);
        ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
          new Phrase("nested layers"), 50, 775, 0
        );
        cb.EndLayer();
        cb.BeginLayer(nested_1);
        ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT,
          new Phrase("nested layer 1"), 100, 800, 0
        );
        cb.EndLayer();
        cb.BeginLayer(nested_2);
        ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, 
          new Phrase("nested layer 2"), 100, 750, 0
        );
        cb.EndLayer();

        PdfLayer group = PdfLayer.CreateTitle("Grouped layers", writer);
        PdfLayer layer1 = new PdfLayer("Group: layer 1", writer);
        PdfLayer layer2 = new PdfLayer("Group: layer 2", writer);
        group.AddChild(layer1);
        group.AddChild(layer2);
        cb.BeginLayer(layer1);
        ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, 
          new Phrase( "layer 1 in the group"), 50, 700, 0
        );
        cb.EndLayer();
        cb.BeginLayer(layer2);
        ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, 
          new Phrase("layer 2 in the group"), 50, 675, 0
        );
        cb.EndLayer();

        PdfLayer radiogroup = PdfLayer.CreateTitle("Radio group", writer);
        PdfLayer radio1 = new PdfLayer("Radiogroup: layer 1", writer);
        radio1.On = true;
        PdfLayer radio2 = new PdfLayer("Radiogroup: layer 2", writer);
        radio2.On = false;
        PdfLayer radio3 = new PdfLayer("Radiogroup: layer 3", writer);
        radio3.On = false;
        radiogroup.AddChild(radio1);
        radiogroup.AddChild(radio2);
        radiogroup.AddChild(radio3);
        List<PdfLayer> options = new List<PdfLayer>();
        options.Add(radio1);
        options.Add(radio2);
        options.Add(radio3);
        writer.AddOCGRadioGroup(options);
        cb.BeginLayer(radio1);
        ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, 
          new Phrase("option 1"), 50, 600, 0
        );
        cb.EndLayer();
        cb.BeginLayer(radio2);
        ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, 
          new Phrase("option 2"), 50, 575, 0
        );
        cb.EndLayer();
        cb.BeginLayer(radio3);
        ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, 
          new Phrase(
                "option 3"
          ), 50, 550, 0
        );
        cb.EndLayer();

        PdfLayer not_printed = new PdfLayer("not printed", writer);
        not_printed.OnPanel = false;
        not_printed.SetPrint("Print", false);
        cb.BeginLayer(not_printed);
        ColumnText.ShowTextAligned(cb, Element.ALIGN_CENTER, 
          new Phrase(
                "PRINT THIS PAGE"
          ), 300, 700, 90
        );
        cb.EndLayer();

        PdfLayer zoom = new PdfLayer("Zoom 0.75-1.25", writer);
        zoom.OnPanel = false;
        zoom.SetZoom(0.75f, 1.25f);
        cb.BeginLayer(zoom);
        ColumnText.ShowTextAligned(
          cb, Element.ALIGN_LEFT, 
          new Phrase(
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


示例20: AddMember

 /**
 * Adds a new member to the layer.
 * @param layer the new member to the layer
 */    
 virtual public void AddMember(PdfLayer layer) {
     if (!layers.ContainsKey(layer)) {
         members.Add(layer.Ref);
         layers[layer] = null;
     }
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:10,代码来源:PdfLayerMembership.cs



注:本文中的iTextSharp.text.pdf.PdfLayer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# pdf.PdfLine类代码示例发布时间:2022-05-26
下一篇:
C# pdf.PdfIndirectReference类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap