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


C# pdf.PdfDestination类代码示例

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


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

示例1: CreateNamedInstanceFor

        public INamedDestination CreateNamedInstanceFor(Dictionary<string, object> iDestination)
        {
            // TODO: Either verify that these settings are okay by default, or make them configuration injectable.
            var uniqueIdentifier = Guid.NewGuid().ToString().Replace("-", string.Empty);
            var page = 0;
            var typeParam = -1.0f;
            var type = 0;
            if (iDestination.ContainsKey("Title"))
            {
                var title = _nameProvider.GetName(iDestination["Title"].ToString());
                if (!string.IsNullOrEmpty(title))
                {
                    uniqueIdentifier = title;
                }
            }
            if (iDestination.ContainsKey("Page"))
            {
                var matches = Regex.Match(iDestination["Page"].ToString(), @"(?'page'\d*) (?'type'\w*) (?'typeParam'\d*)");
                if (!string.IsNullOrEmpty(matches.Groups["page"].Value))
                {
                    page = Int32.Parse(matches.Groups["page"].Value);
                }
                if (!string.IsNullOrEmpty(matches.Groups["type"].Value))
                {
                    type = GetPDFViewType(matches.Groups["type"].Value);
                }
                if (!string.IsNullOrEmpty(matches.Groups["typeParam"].Value))
                {
                    typeParam = float.Parse(matches.Groups["typeParam"].Value);
                }
            }

            var destination = new PdfDestination(type, typeParam);
            return new NamedDestinationImpl(uniqueIdentifier, page, destination);
        }
开发者ID:CaffeineMachine,项目名称:TextSharpUtils,代码行数:35,代码来源:NamedDestinationFactory.cs

示例2: ManipulatePdf

 // ---------------------------------------------------------------------------    
 /**
  * Manipulates a PDF file src with the file dest as result
  * @param src the original PDF
  */
 public byte[] ManipulatePdf(byte[] src)
 {
     // Create the reader
     PdfReader reader = new PdfReader(src);
     int n = reader.NumberOfPages;
     using (MemoryStream ms = new MemoryStream())
     {
         // Create the stamper
         using (PdfStamper stamper = new PdfStamper(reader, ms))
         {
             // Make a list with all the possible actions
             actions = new List<PdfAction>();
             PdfDestination d;
             for (int i = 0; i < n; )
             {
                 d = new PdfDestination(PdfDestination.FIT);
                 actions.Add(PdfAction.GotoLocalPage(++i, d, stamper.Writer));
             }
             // Add a navigation table to every page
             PdfContentByte canvas;
             for (int i = 0; i < n; )
             {
                 canvas = stamper.GetOverContent(++i);
                 CreateNavigationTable(i, n).WriteSelectedRows(0, -1, 696, 36, canvas);
             }
         }
         return ms.ToArray();
     }
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:34,代码来源:TimetableDestinations.cs

示例3: GenPdfDailyBatteryAllCust

        public void GenPdfDailyBatteryAllCust(string TempFolderPath, string ImageFileName, string ReportPeriod, string ProcessDate)
        {
            //this creates a new destination to send the action to when the document is opened. The zoom in this instance is set to 0.75f (75%). Again I use doc.PageSize.Height to set the y coordinate to the top of the page. PdfDestination.XYZ is a specific PdfDestination Type that allows us to set the location and zoom.
            PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, _doc.PageSize.Height, 1.00f);
            _doc.Open();

            string imageURL_VinSplash = Path.Combine(TempFolderPath, "VinCoverPage.png");
            iTextSharp.text.Image jpg_VinSplash = iTextSharp.text.Image.GetInstance(imageURL_VinSplash);

            //Resize image depend upon your need
            jpg_VinSplash.ScalePercent(65f);

            //Give space before image
            jpg_VinSplash.SpacingBefore = 10f;

            //Give some space after the image
            jpg_VinSplash.SpacingAfter = 1f;
            jpg_VinSplash.Alignment = Element.ALIGN_CENTER;

            _doc.Add(jpg_VinSplash);

            PdfPTable table = GenerateBatteryAllCustDashboard(ProcessDate);

            _doc.Add(table);

            GenerateBatteryChartByCustVin(TempFolderPath, ProcessDate);

            PdfAction action = PdfAction.GotoLocalPage(1, pdfDest, _writer);

            //    //set the open action for our writer object
            _writer.SetOpenAction(action);
        }
开发者ID:kiranmath,项目名称:PcanRepository,代码行数:32,代码来源:CreateReports.cs

示例4: ManipulatePdf

 public void ManipulatePdf(String src, String dest)
 {
     PdfReader reader = new PdfReader(src);
     PdfStamper stamper = new PdfStamper(reader, new FileStream(dest, FileMode.Create));
     Rectangle linkLocation = new Rectangle(523, 770, 559, 806);
     PdfDestination destination = new PdfDestination(PdfDestination.FIT);
     PdfAnnotation link = PdfAnnotation.CreateLink(stamper.Writer,
         linkLocation, PdfAnnotation.HIGHLIGHT_INVERT,
         3, destination);
     stamper.AddAnnotation(link, 1);
     stamper.Close();
 }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:12,代码来源:AddLinkAnnotation.cs

示例5: AddNavigationTest

 public void AddNavigationTest()  {
     String src = srcFolder + "primes.pdf";
     String dest = outFolder + "primes_links.pdf";
     PdfReader reader = new PdfReader(src);
     PdfStamper stamper = new PdfStamper(reader, new FileStream(dest, FileMode.Create));
     PdfDestination d = new PdfDestination(PdfDestination.FIT);
     Rectangle rect = new Rectangle(0, 806, 595, 842);
     PdfAnnotation a10 = PdfAnnotation.CreateLink(stamper.Writer, rect, PdfAnnotation.HIGHLIGHT_INVERT, 2, d);
     stamper.AddAnnotation(a10, 1);
     PdfAnnotation a1 = PdfAnnotation.CreateLink(stamper.Writer, rect, PdfAnnotation.HIGHLIGHT_PUSH, 1, d);
     stamper.AddAnnotation(a1, 2);
     stamper.Close();
     CompareTool compareTool = new CompareTool();
     String errorMessage = compareTool.CompareByContent(dest, srcFolder + "cmp_primes_links.pdf", outFolder, "diff_");
     if (errorMessage != null) {
         Assert.Fail(errorMessage);
     }
 }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:18,代码来源:NamedDestinationsTest.cs

示例6: CreateMoviePage

 // ---------------------------------------------------------------------------
 /**
  * Creates the PDF.
  * @return the bytes of a PDF file.
  */
 public byte[] CreateMoviePage(Movie movie)
 {
     using (MemoryStream ms = new MemoryStream()) {
     // step 1
     using (Document document = new Document()) {
       // step 2
       PdfWriter.GetInstance(document, ms);
       // step 3
       document.Open();
       // step 4
       Paragraph p = new Paragraph(
     movie.MovieTitle,
     FontFactory.GetFont(
       BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED, 16
     )
       );
       document.Add(p);
       document.Add(Chunk.NEWLINE);
       PdfPTable table = new PdfPTable(WIDTHS);
       table.AddCell(Image.GetInstance(
     String.Format(RESOURCE, movie.Imdb)
       ));
       PdfPCell cell = new PdfPCell();
       cell.AddElement(new Paragraph("Year: " + movie.Year.ToString()));
       cell.AddElement(new Paragraph("Duration: " + movie.Duration.ToString()));
       table.AddCell(cell);
       document.Add(table);
       PdfDestination dest = new PdfDestination(PdfDestination.FIT);
       dest.AddFirst(new PdfNumber(1));
       PdfTargetDictionary target = new PdfTargetDictionary(false);
       Chunk chunk = new Chunk("Go to original document");
       PdfAction action = PdfAction.GotoEmbedded(null, target, dest, false);
       chunk.SetAction(action);
       document.Add(chunk);
     }
     return ms.ToArray();
       }
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:43,代码来源:KubrickBox.cs

示例7: PdfOutline

 /**
  * Constructs a <CODE>PdfOutline</CODE>.
  * <P>
  * This is the constructor for an <CODE>outline entry</CODE>.
  *
  * @param parent the parent of this outline item
  * @param destination the destination for this outline item
  * @param title the title of this outline item
  * @param open <CODE>true</CODE> if the children are visible
  */
 public PdfOutline(PdfOutline parent, PdfDestination destination, string title, bool open)
     : base()
 {
     this.destination = destination;
     InitOutline(parent, title, open);
 }
开发者ID:medvedttn,项目名称:itextsharp_mod-src,代码行数:16,代码来源:PdfOutline.cs

示例8: LocalDestination

 /**
  * The local destination to where a local goto with the same
  * name will jump.
  * @param name the name of this local destination
  * @param destination the <CODE>PdfDestination</CODE> with the jump coordinates
  * @return <CODE>true</CODE> if the local destination was added,
  * <CODE>false</CODE> if a local destination with the same name
  * already exists
  */
 public bool LocalDestination(string name, PdfDestination destination)
 {
     return pdf.LocalDestination(name, destination);
 }
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:13,代码来源:PdfContentByte.cs

示例9: Write

 public override void Write(PdfWriter writer, Document doc) {
     PdfDestination destination = new PdfDestination(PdfDestination.XYZ, 20,
             writer.GetVerticalPosition(false), 0);
     IDictionary<String, Object> memory = context.GetMemory();
     HeaderNode tree = null;
     if (memory.ContainsKey(HtmlPipelineContext.BOOKMARK_TREE))
         tree = (HeaderNode)memory[HtmlPipelineContext.BOOKMARK_TREE];
     int level = header.GetLevel(tag);
     if (null == tree) {
         // first h tag encounter
         tree = new HeaderNode(0, writer.RootOutline, null);
     }
     else {
         // calculate parent
         int lastLevel = tree.Level;
         if (lastLevel == level) {
             tree = tree.Parent;
         }
         else if (lastLevel > level) {
             while (lastLevel >= level) {
                 lastLevel = tree.Parent.Level;
                 tree = tree.Parent;
             }
         }
     }
     if (LOGGER.IsLogging(Level.TRACE)) {
         LOGGER.Trace(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.ADD_HEADER), title.ToString()));
     }
     HeaderNode node = new HeaderNode(level, new PdfOutline(tree.Outline, destination, title), tree);
     memory[HtmlPipelineContext.BOOKMARK_TREE] = node;
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:31,代码来源:Header.cs

示例10: PdfNamedDestinationsOverflow

        public void PdfNamedDestinationsOverflow() {
            Document document = new Document();
            PdfAWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT + "pdfNamedDestinationsOverflow.pdf", FileMode.Create), PdfAConformanceLevel.PDF_A_1A);
            writer.CreateXmpMetadata();
            writer.SetTagged();
            document.Open();
            document.AddLanguage("en-US");

            Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
            document.Add(new Paragraph("Hello World", font));
            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);

            PdfDocument pdf = writer.PdfDocument;
            for (int i = 0; i < 8200; i++) {
                PdfDestination dest = new PdfDestination(PdfDestination.FITV);
                pdf.LocalDestination("action" + i, dest);
            }
            document.Close();
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:23,代码来源:PdfA1CheckerTest.cs

示例11: GotoLocalPage

 /** Creates a GoTo action to an internal page.
  * @param page the page to go. First page is 1
  * @param dest the destination for the page
  * @param writer the writer for this action
  * @return a GoTo action
  */    
 public static PdfAction GotoLocalPage(int page, PdfDestination dest, PdfWriter writer) {
     PdfIndirectReference piref = writer.GetPageReference(page);
     PdfDestination d = new PdfDestination(dest);
     d.AddPage(piref);
     PdfAction action = new PdfAction();
     action.Put(PdfName.S, PdfName.GOTO);
     action.Put(PdfName.D, d);
     return action;
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:15,代码来源:PdfAction.cs

示例12: AppendOutline

 /// <summary>
 /// 新しいアウトラインを登録する
 /// </summary>
 /// <param name="level">階層構造のレベル(1以上)</param>
 /// <param name="title">見出し文字列</param>
 /// <param name="cb">PDFデータ</param>
 /// <returns>生成されたアウトラインのパス</returns>
 public void AppendOutline(int level, UString title, PdfContentByte cb)
 {
     AppendOutlineNode(level, title);
     var path = Path(_currentNode);
     var destination = new PdfDestination(PdfDestination.INDIRECT);
     var added = cb.LocalDestination(path, destination);
 }
开发者ID:karak,项目名称:Geovanni,代码行数:14,代码来源:PdfOutlineBuilder.cs

示例13: OnParagraph

 public override void OnParagraph(PdfWriter writer, Document document, float position) {
     PdfContentByte cb = writer.DirectContent;
     PdfDestination destination = new PdfDestination(PdfDestination.FITH, position);
     new PdfOutline(cb.RootOutline, destination, TITLE);
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:5,代码来源:BookmarksTest.cs

示例14: LocalDestination

 /**
 * The local destination to where a local goto with the same
 * name will jump to.
 * @param name the name of this local destination
 * @param destination the <CODE>PdfDestination</CODE> with the jump coordinates
 * @return <CODE>true</CODE> if the local destination was added,
 * <CODE>false</CODE> if a local destination with the same name
 * already existed
 */
 internal bool LocalDestination(String name, PdfDestination destination) {
     Destination dest;
     if (localDestinations.ContainsKey(name))
         dest = localDestinations[name];
     else
         dest = new Destination();
     if (dest.destination != null)
         return false;
     dest.destination = destination;
     localDestinations[name] = dest;
     if (!destination.HasPage())
         destination.AddPage(writer.CurrentPage);
     return true;
 }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:23,代码来源:PdfDocument.cs

示例15: AddNamedDestination

 /**
 * Adds one named destination.
 * @param    name    the name for the destination
 * @param    page    the page number where you want to jump to
 * @param    dest    an explicit destination
 * @since    iText 5.0
 */
 virtual public void AddNamedDestination(String name, int page, PdfDestination dest) {
     PdfDestination d = new PdfDestination(dest);
     d.AddPage(GetPageReference(page));
     pdf.LocalDestination(name, d);
 }
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:12,代码来源:PdfWriter.cs


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