private void BuildLinks( Document document ) { Pages pages = document.Pages; Page page = new Page(document); pages.Add(page); StandardType1Font font = new StandardType1Font( document, StandardType1Font.FamilyEnum.Courier, true, false ); PrimitiveComposer composer = new PrimitiveComposer(page); BlockComposer blockComposer = new BlockComposer(composer); /* 2.1. Goto-URI link. */ { blockComposer.Begin(new RectangleF(30,100,200,50),XAlignmentEnum.Left,YAlignmentEnum.Middle); composer.SetFont(font,12); blockComposer.ShowText("Go-to-URI link"); composer.SetFont(font,8); blockComposer.ShowText("\nIt allows you to navigate to a network resource."); composer.SetFont(font,5); blockComposer.ShowText("\n\nClick on the box to go to the project's SourceForge.net repository."); blockComposer.End(); try { /* NOTE: This statement instructs the PDF viewer to navigate to the given URI when the link is clicked. */ annotations::Link link = new annotations::Link( page, new Rectangle(240,100,100,50), "Link annotation", new GoToURI( document, new Uri("http://www.sourceforge.net/projects/clown") ) ); link.Border = new annotations::Border( document, 3, annotations::Border.StyleEnum.Beveled, null ); } catch(Exception exception) {throw new Exception("",exception);} } /* 2.2. Embedded-goto link. */ { string filePath = PromptFileChoice("Please select a PDF file to attach"); /* NOTE: These statements instruct PDF Clown to attach a PDF file to the current document. This is necessary in order to test the embedded-goto functionality, as you can see in the following link creation (see below). */ int fileAttachmentPageIndex = page.Index; string fileAttachmentName = "attachedSamplePDF"; string fileName = System.IO.Path.GetFileName(filePath); annotations::FileAttachment attachment = new annotations::FileAttachment( page, new Rectangle(0, -20, 10, 10), "File attachment annotation", FileSpecification.Get( EmbeddedFile.Get( document, filePath ), fileName ) ); attachment.Name = fileAttachmentName; attachment.IconType = annotations::FileAttachment.IconTypeEnum.PaperClip; blockComposer.Begin(new RectangleF(30,170,200,50),XAlignmentEnum.Left,YAlignmentEnum.Middle); composer.SetFont(font,12); blockComposer.ShowText("Go-to-embedded link"); composer.SetFont(font,8); blockComposer.ShowText("\nIt allows you to navigate to a destination within an embedded PDF file."); composer.SetFont(font,5); blockComposer.ShowText("\n\nClick on the button to go to the 2nd page of the attached PDF file (" + fileName + ")."); blockComposer.End(); /* NOTE: This statement instructs the PDF viewer to navigate to the page 2 of a PDF file attached inside the current document as described by the FileAttachment annotation on page 1 of the current document. */ annotations::Link link = new annotations::Link( page, new Rectangle(240,170,100,50), "Link annotation", new GoToEmbedded( document, new GoToEmbedded.PathElement( document, fileAttachmentPageIndex, // Page of the current document containing the file attachment annotation of the target document. fileAttachmentName, // Name of the file attachment annotation corresponding to the target document. null // No sub-target. ), // Target represents the document to go to. new RemoteDestination( document, 1, // Show the page 2 of the target document. Destination.ModeEnum.Fit, // Show the target document page entirely on the screen. null, null ) // The destination must be within the target document. ) ); link.Border = new annotations::Border( document, 1, annotations::Border.StyleEnum.Dashed, new LineDash(new double[]{8,5,2,5}) ); } /* 2.3. Textual link. */ { blockComposer.Begin(new RectangleF(30,240,200,50),XAlignmentEnum.Left,YAlignmentEnum.Middle); composer.SetFont(font,12); blockComposer.ShowText("Textual link"); composer.SetFont(font,8); blockComposer.ShowText("\nIt allows you to expose any kind of link (including the above-mentioned types) as text."); composer.SetFont(font,5); blockComposer.ShowText("\n\nClick on the text links to go either to the project's SourceForge.net repository or to the project's home page."); blockComposer.End(); try { composer.BeginLocalState(); composer.SetFont(font,10); composer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.Blue)); composer.ShowText( "PDF Clown Project's repository at SourceForge.net", new PointF(240,265), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0, new GoToURI( document, new Uri("http://www.sourceforge.net/projects/clown") ) ); composer.ShowText( "PDF Clown Project's home page", new PointF(240,285), XAlignmentEnum.Left, YAlignmentEnum.Bottom, -90, new GoToURI( document, new Uri("http://www.pdfclown.org") ) ); composer.End(); } catch {} } composer.Flush(); }
private void Populate( Document document ) { Page page = new Page(document); document.Pages.Add(page); PrimitiveComposer composer = new PrimitiveComposer(page); StandardType1Font font = new StandardType1Font( document, StandardType1Font.FamilyEnum.Courier, true, false ); composer.SetFont(font, 12); // Note. composer.ShowText("Note annotation:", new Point(35, 35)); annotations::Note note = new annotations::Note( page, new Point(50, 50), "Note annotation" ); note.IconType = annotations::Note.IconTypeEnum.Help; note.ModificationDate = new DateTime(); note.IsOpen = true; // Callout. composer.ShowText("Callout note annotation:", new Point(35, 85)); annotations::CalloutNote calloutNote = new annotations::CalloutNote( page, new Rectangle(50, 100, 200, 24), "Callout note annotation" ); calloutNote.Justification = JustificationEnum.Right; calloutNote.Line = new annotations::CalloutNote.LineObject( page, new Point(150, 650), new Point(100, 600), new Point(50, 100) ); // File attachment. composer.ShowText("File attachment annotation:", new Point(35, 135)); annotations::FileAttachment attachment = new annotations::FileAttachment( page, new Rectangle(50, 150, 12, 12), "File attachment annotation", FileSpecification.Get( EmbeddedFile.Get( document, GetResourcePath("images" + Path.DirectorySeparatorChar + "gnu.jpg") ), "happyGNU.jpg" ) ); attachment.IconType = annotations::FileAttachment.IconTypeEnum.PaperClip; composer.BeginLocalState(); // Arrow line. composer.ShowText("Line annotation:", new Point(35, 185)); composer.SetFont(font, 10); composer.ShowText("Arrow:", new Point(50, 200)); annotations::Line line = new annotations::Line( page, new Point(50, 260), new Point(200, 210), "Arrow line annotation" ); line.FillColor = new DeviceRGBColor(1, 0, 0); line.StartStyle = annotations::Line.LineEndStyleEnum.Circle; line.EndStyle = annotations::Line.LineEndStyleEnum.ClosedArrow; line.CaptionVisible = true; // Dimension line. composer.ShowText("Dimension:", new Point(300, 200)); line = new annotations::Line( page, new Point(300, 220), new Point(500, 220), "Dimension line annotation" ); line.LeaderLineLength = 20; line.LeaderLineExtensionLength = 10; line.CaptionVisible = true; composer.End(); // Scribble. composer.ShowText("Scribble annotation:", new Point(35, 285)); new annotations::Scribble( page, new RectangleF(50, 300, 100, 30), "Scribble annotation", new List <IList <PointF> >( new List <PointF>[] { new List <PointF>( new PointF[] { new PointF(50, 300), new PointF(70, 310), new PointF(100, 320) } ) } ) ); // Rectangle. composer.ShowText("Rectangle annotation:", new Point(35, 335)); annotations::Rectangle rectangle = new annotations::Rectangle( page, new Rectangle(50, 350, 100, 30), "Rectangle annotation" ); rectangle.FillColor = new DeviceRGBColor(1, 0, 0); // Ellipse. composer.ShowText("Ellipse annotation:", new Point(35, 385)); annotations::Ellipse ellipse = new annotations::Ellipse( page, new Rectangle(50, 400, 100, 30), "Ellipse annotation" ); ellipse.FillColor = new DeviceRGBColor(0, 0, 1); // Rubber stamp. composer.ShowText("Rubber stamp annotation:", new Point(35, 435)); new annotations::RubberStamp( page, new Rectangle(50, 450, 100, 30), "Rubber stamp annotation", annotations::RubberStamp.IconTypeEnum.Approved ); // Caret. composer.ShowText("Caret annotation:", new Point(35, 485)); annotations::Caret caret = new annotations::Caret( page, new Rectangle(50, 500, 100, 30), "Caret annotation" ); caret.SymbolType = annotations::Caret.SymbolTypeEnum.NewParagraph; composer.Flush(); }
private void BuildLinks( Document document ) { Pages pages = document.Pages; Page page = new Page(document); pages.Add(page); StandardType1Font font = new StandardType1Font( document, StandardType1Font.FamilyEnum.Courier, true, false ); PrimitiveComposer composer = new PrimitiveComposer(page); BlockComposer blockComposer = new BlockComposer(composer); /* * 2.1. Goto-URI link. */ { blockComposer.Begin(new RectangleF(30, 100, 200, 50), XAlignmentEnum.Left, YAlignmentEnum.Middle); composer.SetFont(font, 12); blockComposer.ShowText("Go-to-URI link"); composer.SetFont(font, 8); blockComposer.ShowText("\nIt allows you to navigate to a network resource."); composer.SetFont(font, 5); blockComposer.ShowText("\n\nClick on the box to go to the project's SourceForge.net repository."); blockComposer.End(); try { /* * NOTE: This statement instructs the PDF viewer to navigate to the given URI when the link is clicked. */ annotations::Link link = new annotations::Link( page, new Rectangle(240, 100, 100, 50), "Link annotation", new GoToURI( document, new Uri("http://www.sourceforge.net/projects/clown") ) ); link.Border = new annotations::Border( document, 3, annotations::Border.StyleEnum.Beveled, null ); } catch (Exception exception) { throw new Exception("", exception); } } /* * 2.2. Embedded-goto link. */ { string filePath = PromptFileChoice("Please select a PDF file to attach"); /* * NOTE: These statements instruct PDF Clown to attach a PDF file to the current document. * This is necessary in order to test the embedded-goto functionality, * as you can see in the following link creation (see below). */ int fileAttachmentPageIndex = page.Index; string fileAttachmentName = "attachedSamplePDF"; string fileName = System.IO.Path.GetFileName(filePath); annotations::FileAttachment attachment = new annotations::FileAttachment( page, new Rectangle(0, -20, 10, 10), "File attachment annotation", FileSpecification.Get( EmbeddedFile.Get( document, filePath ), fileName ) ); attachment.Name = fileAttachmentName; attachment.IconType = annotations::FileAttachment.IconTypeEnum.PaperClip; blockComposer.Begin(new RectangleF(30, 170, 200, 50), XAlignmentEnum.Left, YAlignmentEnum.Middle); composer.SetFont(font, 12); blockComposer.ShowText("Go-to-embedded link"); composer.SetFont(font, 8); blockComposer.ShowText("\nIt allows you to navigate to a destination within an embedded PDF file."); composer.SetFont(font, 5); blockComposer.ShowText("\n\nClick on the button to go to the 2nd page of the attached PDF file (" + fileName + ")."); blockComposer.End(); /* * NOTE: This statement instructs the PDF viewer to navigate to the page 2 of a PDF file * attached inside the current document as described by the FileAttachment annotation on page 1 of the current document. */ annotations::Link link = new annotations::Link( page, new Rectangle(240, 170, 100, 50), "Link annotation", new GoToEmbedded( document, new GoToEmbedded.PathElement( document, fileAttachmentPageIndex, // Page of the current document containing the file attachment annotation of the target document. fileAttachmentName, // Name of the file attachment annotation corresponding to the target document. null // No sub-target. ), // Target represents the document to go to. new RemoteDestination( document, 1, // Show the page 2 of the target document. Destination.ModeEnum.Fit, // Show the target document page entirely on the screen. null, null ) // The destination must be within the target document. ) ); link.Border = new annotations::Border( document, 1, annotations::Border.StyleEnum.Dashed, new LineDash(new double[] { 8, 5, 2, 5 }) ); } /* * 2.3. Textual link. */ { blockComposer.Begin(new RectangleF(30, 240, 200, 50), XAlignmentEnum.Left, YAlignmentEnum.Middle); composer.SetFont(font, 12); blockComposer.ShowText("Textual link"); composer.SetFont(font, 8); blockComposer.ShowText("\nIt allows you to expose any kind of link (including the above-mentioned types) as text."); composer.SetFont(font, 5); blockComposer.ShowText("\n\nClick on the text links to go either to the project's SourceForge.net repository or to the project's home page."); blockComposer.End(); try { composer.BeginLocalState(); composer.SetFont(font, 10); composer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.Blue)); composer.ShowText( "PDF Clown Project's repository at SourceForge.net", new PointF(240, 265), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0, new GoToURI( document, new Uri("http://www.sourceforge.net/projects/clown") ) ); composer.ShowText( "PDF Clown Project's home page", new PointF(240, 285), XAlignmentEnum.Left, YAlignmentEnum.Bottom, -90, new GoToURI( document, new Uri("http://www.pdfclown.org") ) ); composer.End(); } catch {} } composer.Flush(); }
private void Populate( Document document ) { Page page = new Page(document); document.Pages.Add(page); PrimitiveComposer composer = new PrimitiveComposer(page); StandardType1Font font = new StandardType1Font( document, StandardType1Font.FamilyEnum.Courier, true, false ); composer.SetFont(font,12); // Note. composer.ShowText("Note annotation:", new Point(35,35)); annotations::Note note = new annotations::Note( page, new Point(50, 50), "Note annotation" ); note.IconType = annotations::Note.IconTypeEnum.Help; note.ModificationDate = new DateTime(); note.IsOpen = true; // Callout. composer.ShowText("Callout note annotation:", new Point(35,85)); annotations::CalloutNote calloutNote = new annotations::CalloutNote( page, new Rectangle(50, 100, 200, 24), "Callout note annotation" ); calloutNote.Justification = JustificationEnum.Right; calloutNote.Line = new annotations::CalloutNote.LineObject( page, new Point(150,650), new Point(100,600), new Point(50,100) ); // File attachment. composer.ShowText("File attachment annotation:", new Point(35,135)); annotations::FileAttachment attachment = new annotations::FileAttachment( page, new Rectangle(50, 150, 12, 12), "File attachment annotation", FileSpecification.Get( EmbeddedFile.Get( document, GetResourcePath("images" + Path.DirectorySeparatorChar + "gnu.jpg") ), "happyGNU.jpg" ) ); attachment.IconType = annotations::FileAttachment.IconTypeEnum.PaperClip; composer.BeginLocalState(); // Arrow line. composer.ShowText("Line annotation:", new Point(35,185)); composer.SetFont(font,10); composer.ShowText("Arrow:", new Point(50,200)); annotations::Line line = new annotations::Line( page, new Point(50, 260), new Point(200,210), "Arrow line annotation" ); line.FillColor = new DeviceRGBColor(1,0,0); line.StartStyle = annotations::Line.LineEndStyleEnum.Circle; line.EndStyle = annotations::Line.LineEndStyleEnum.ClosedArrow; line.CaptionVisible = true; // Dimension line. composer.ShowText("Dimension:", new Point(300,200)); line = new annotations::Line( page, new Point(300,220), new Point(500,220), "Dimension line annotation" ); line.LeaderLineLength = 20; line.LeaderLineExtensionLength = 10; line.CaptionVisible = true; composer.End(); // Scribble. composer.ShowText("Scribble annotation:", new Point(35,285)); new annotations::Scribble( page, new RectangleF(50, 300, 100, 30), "Scribble annotation", new List<IList<PointF>>( new List<PointF>[] { new List<PointF>( new PointF[] { new PointF(50,300), new PointF(70,310), new PointF(100,320) } ) } ) ); // Rectangle. composer.ShowText("Rectangle annotation:", new Point(35,335)); annotations::Rectangle rectangle = new annotations::Rectangle( page, new Rectangle(50, 350, 100, 30), "Rectangle annotation" ); rectangle.FillColor = new DeviceRGBColor(1,0,0); rectangle.Alpha = .25; // Ellipse. composer.ShowText("Ellipse annotation:", new Point(35,385)); annotations::Ellipse ellipse = new annotations::Ellipse( page, new Rectangle(50, 400, 100, 30), "Ellipse annotation" ); ellipse.FillColor = new DeviceRGBColor(0,0,1); // Rubber stamp. composer.ShowText("Rubber stamp annotation:", new Point(35,435)); new annotations::RubberStamp( page, new Rectangle(50, 450, 100, 30), "Rubber stamp annotation", annotations::RubberStamp.IconTypeEnum.Approved ); // Caret. composer.ShowText("Caret annotation:", new Point(35,485)); annotations::Caret caret = new annotations::Caret( page, new Rectangle(50, 500, 100, 30), "Caret annotation" ); caret.SymbolType = annotations::Caret.SymbolTypeEnum.NewParagraph; composer.Flush(); }