当前位置: 首页>>代码示例>>C#>>正文


C# Chunk.SetNewPage方法代码示例

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


在下文中一共展示了Chunk.SetNewPage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleStartingTags


//.........这里部分代码省略.........
                    throw de;
                }
            }
        
            // newlines
            if (IsNewline(name)) {
                ITextElementArray current;
                try {
                    current = (ITextElementArray) stack.Pop();
                    current.Add(Chunk.NEWLINE);
                    stack.Push(current);
                }
                catch {
                    if (currentChunk == null) {
                        try {
                            document.Add(Chunk.NEWLINE);
                        }
                        catch (DocumentException de) {
                            throw de;
                        }
                    }
                    else {
                        currentChunk.Append("\n");
                    }
                }
                return;
            }
        
            // newpage
            if (IsNewpage(name)) {
                ITextElementArray current;
                try {
                    current = (ITextElementArray) stack.Pop();
                    Chunk newPage = new Chunk("");
                    newPage.SetNewPage();
                    if (bf != null) {
                        newPage.Font = new Font(this.bf);
                    }
                    current.Add(newPage);
                    stack.Push(current);
                }
                catch {
                    document.NewPage();
                }
                return;
            }
        
            if (ElementTags.HORIZONTALRULE.Equals(name)) {
                ITextElementArray current;
                LineSeparator hr = new LineSeparator(1.0f, 100.0f, null, Element.ALIGN_CENTER, 0);
                try {
                    current = (ITextElementArray)stack.Pop();
                    current.Add(hr);
                    stack.Push(current);
                } catch (InvalidOperationException) {
                    document.Add(hr);
                }
                return;
            }
            
            // documentroot
            if (IsDocumentRoot(name)) {
                String value;
                // pagesize and orientation specific code suggested by Samuel Gabriel
                // Updated by Ricardo Coutinho. Only use if set in html!
                Rectangle pageSize = null;
                String orientation = null;
                foreach (string key in attributes.Keys) {
                    value = attributes[key];
                    // margin specific code suggested by Reza Nasiri
                    if (Util.EqualsIgnoreCase(ElementTags.LEFT, key))
                        leftMargin = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    if (Util.EqualsIgnoreCase(ElementTags.RIGHT, key))
                        rightMargin = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    if (Util.EqualsIgnoreCase(ElementTags.TOP, key))
                        topMargin = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    if (Util.EqualsIgnoreCase(ElementTags.BOTTOM, key))
                        bottomMargin = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    if (ElementTags.PAGE_SIZE.Equals(key)) {
                        pageSize = (Rectangle)typeof(PageSize).GetField(value).GetValue(null);
                    } else if (ElementTags.ORIENTATION.Equals(key)) {
                        if ("landscape".Equals(value)) {
                            orientation = "landscape";
                        }
                    } else {
                        document.Add(new Meta(key, value));
                    }
                }
                if (pageSize != null) {
                    if ("landscape".Equals(orientation)) {
                        pageSize = pageSize.Rotate();
                    }
                    document.SetPageSize(pageSize);
                }
                document.SetMargins(leftMargin, rightMargin, topMargin,
                        bottomMargin);
                if (controlOpenClose)
                    document.Open();
            }
        }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:101,代码来源:ITextHandler.cs

示例2: HandleStartingTags


//.........这里部分代码省略.........
                            current.Add(annotation);
                        }
                        catch {
                            document.Add(annotation);
                        }
                        stack.Push(current);
                    }
                    catch {
                        document.Add(annotation);
                    }
                    return;
                }
                catch (DocumentException de) {
                    throw new Exception("", de);
                }
            }

            // newlines
            if (IsNewline(name)) {
                ITextElementArray current;
                try {
                    current = (ITextElementArray) stack.Pop();
                    current.Add(Chunk.NEWLINE);
                    stack.Push(current);
                }
                catch {
                    if (currentChunk == null) {
                        try {
                            document.Add(Chunk.NEWLINE);
                        }
                        catch (DocumentException de) {
                            throw new Exception("", de);
                        }
                    }
                    else {
                        currentChunk.Append("\n");
                    }
                }
                return;
            }

            // newpage
            if (IsNewpage(name)) {
                ITextElementArray current;
                try {
                    current = (ITextElementArray) stack.Pop();
                    Chunk newPage = new Chunk("");
                    newPage.SetNewPage();
                    if (bf != null) {
                        newPage.Font = new Font(this.bf);
                    }
                    current.Add(newPage);
                    stack.Push(current);
                }
                catch {
                    document.NewPage();
                }
                return;
            }

            // documentroot
            if (IsDocumentRoot(name)) {
                String value;
                // pagesize and orientation specific code suggested by Samuel Gabriel
                // Updated by Ricardo Coutinho. Only use if set in html!
                Rectangle pageSize = null;
                String orientation = null;
                foreach (string key in attributes.Keys) {
                    value = attributes[key];
                    // margin specific code suggested by Reza Nasiri
                    if (Util.EqualsIgnoreCase(ElementTags.LEFT, key))
                        leftMargin = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    if (Util.EqualsIgnoreCase(ElementTags.RIGHT, key))
                        rightMargin = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    if (Util.EqualsIgnoreCase(ElementTags.TOP, key))
                        topMargin = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    if (Util.EqualsIgnoreCase(ElementTags.BOTTOM, key))
                        bottomMargin = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    if (ElementTags.PAGE_SIZE.Equals(key)) {
                        pageSize = (Rectangle)typeof(PageSize).GetField(value).GetValue(null);
                    } else if (ElementTags.ORIENTATION.Equals(key)) {
                        if ("landscape".Equals(value)) {
                            orientation = "landscape";
                        }
                    } else {
                        document.Add(new Meta(key, value));
                    }
                }
                if(pageSize != null) {
                    if ("landscape".Equals(orientation)) {
                        pageSize = pageSize.Rotate();
                    }
                    document.SetPageSize(pageSize);
                }
                document.SetMargins(leftMargin, rightMargin, topMargin,
                        bottomMargin);
                if (controlOpenClose)
                    document.Open();
            }
        }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:101,代码来源:ITextHandler.cs


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