當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。