Outlines and Destinations

编程入门 行业动态 更新时间:2024-10-11 21:22:39

Outlines and <a href=https://www.elefans.com/category/jswz/34/1425593.html style=Destinations"/>

Outlines and Destinations

2019独角兽企业重金招聘Python工程师标准>>>

Console.WriteLine("Chapter 11 example 7: Outlines and Destinations");
// step 1: creation of a document-object Document document = new Document();
try {
// step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("d:/pdf/Chap1107.pdf", FileMode.Create));
// step 3: we open the document document.Open();
// step 4: we grab the ContentByte and do some stuff with it PdfContentByte cb = writer.DirectContent;
// we create a PdfTemplate PdfTemplate template = cb.CreateTemplate(25, 25);
// we add some crosses to visualize the destinations template.MoveTo(13, 0); template.LineTo(13, 25); template.MoveTo(0, 13); template.LineTo(50, 13); template.Stroke();
// we add the template on different positions cb.AddTemplate(template, 287, 787); cb.AddTemplate(template, 187, 487); cb.AddTemplate(template, 487, 287); cb.AddTemplate(template, 87, 87);
var moreRecordRef = new Chunk("link A"); moreRecordRef.SetLocalGoto("more"); //moreAnchor.SetLocalDestination("#more");
// we define the destinations PdfDestination d1 = new PdfDestination(PdfDestination.XYZ, 300, 800, 0); PdfOutline out1 = new PdfOutline(cb.RootOutline, d1, "root"); PdfDestination d2 = new PdfDestination(PdfDestination.FITH, 500);                 PdfDestination d3 = new PdfDestination(PdfDestination.FITR, 200, 300, 400, 500);                 PdfDestination d4 = new PdfDestination(PdfDestination.FITBV, 100);                 PdfDestination d5 = new PdfDestination(PdfDestination.FIT);
// we define the outlines PdfOutline out2 = new PdfOutline(out1, d2, "sub 1"); PdfOutline out3 = new PdfOutline(out1, d3, "sub 2"); PdfOutline out4 = new PdfOutline(out1, d4, "sub 2.1"); PdfOutline out5 = new PdfOutline(out1, d5, "sub 2.2"); cb.AddOutline(out1); cb.AddOutline(out2); cb.AddOutline(out3); cb.AddOutline(out4); cb.AddOutline(out5);   } catch (DocumentException de) { Console.Error.WriteLine(de.Message); } catch (IOException ioe) { Console.Error.WriteLine(ioe.Message); }
// step 5: we close the document document.Close(); }

转载于:

更多推荐

Outlines and Destinations

本文发布于:2024-02-05 11:03:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1745265.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Outlines   Destinations

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!