public void TestOBJToRAMMeshConverter()
        {
            var c = new OBJToRAMMeshConverter(new RAMTextureFactory());


            var fsMat = new FileStream(TestFiles.CrateMtl, FileMode.Open);


            var importer = new ObjImporter();

            importer.AddMaterialFileStream("Crate01.mtl", fsMat);
            importer.ImportObjFile(TestFiles.CrateObj);


            fsMat.Close();



            var mesh = c.CreateMesh(importer);

            importer = new ObjImporter();
            importer.AddMaterialFileStream("CollisionModelBoxes001.mtl",
                                           EmbeddedFile.GetStream("MHGameWork.TheWizards.Tests.Physics.Files.CollisionModelBoxes001.mtl",
                                                                  "CollisionModelBoxes001.mtl"));
            importer.ImportObjFile(EmbeddedFile.GetStream("MHGameWork.TheWizards.Tests.Physics.Files.CollisionModelBoxes001.obj", "CollisionModelBoxes001.obj"));

            mesh = c.CreateMesh(importer);
        }
Esempio n. 2
0
        private GraphNode ParseField(Field field, EmbeddedFile file)
        {
            switch (field.Type)
            {
            case FieldType.uint32:
            {
                uint fieldValue = file.ReadUInt32();
                return(new GraphNode(field.Name, NodeType.Primitive_uint32, file.Position - sizeof(UInt32),
                                     fieldValue));
            }

            case FieldType.uint16:
            {
                UInt16 fieldValue = file.ReadUInt16();
                return(new GraphNode(field.Name, NodeType.Primitive_uint16, file.Position - sizeof(UInt16),
                                     fieldValue));
            }

            case FieldType.single:
            {
                Single fieldValueSingle = file.ReadSingle();
                return(new GraphNode(field.Name, NodeType.Primitive_single, file.Position - sizeof(Single),
                                     fieldValueSingle));
            }

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 3
0
        private void loadSpriteFont()
        {
            // The spritefont is stored as an embedded assembly file. Since the dumb content manager does not support loading from stream
            //   we first have to store the file on disk before when can load it.

            //TODO: find a way to load directly from stream

            string filename = System.Windows.Forms.Application.StartupPath + "\\Content\\Calibri.xnb";

            if (!System.IO.Directory.Exists(System.Windows.Forms.Application.StartupPath + "\\Content"))
            {
                System.IO.Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\\Content");
            }

            if (!System.IO.File.Exists(filename))
            {
                Stream strm = EmbeddedFile.GetStream("MHGameWork.TheWizards.Core.Graphics.Files.Calibri.xnb", "Calibri.xnb");
                byte[] data = new byte[strm.Length];
                strm.Read(data, 0, (int)strm.Length);

                System.IO.File.WriteAllBytes(filename, data);

                data = null;
                strm.Close();
            }



            spriteFont = Content.Load <SpriteFont>("Content\\Calibri");
        }
 /**
  * <summary>Creates a new reference to an embedded file.</summary>
  * <param name="embeddedFile">Embedded file corresponding to the reference.</param>
  * <param name="filename">Name corresponding to the reference.</param>
  */
 public static FullFileSpecification Get(
     EmbeddedFile embeddedFile,
     string filename
     )
 {
     return(new FullFileSpecification(embeddedFile, filename));
 }
Esempio n. 5
0
        private Stream GetStream(string filename)
        {
#if DEBUG
            return(File.OpenRead(Path.Combine(DebugResourcesDir, filename)));
#else
            return(EmbeddedFile.GetStream(filename));
#endif
        }
Esempio n. 6
0
        private bool FileExists(string filename)
        {
#if DEBUG
            return(File.Exists(Path.Combine(DebugResourcesDir, filename)));
#else
            return(EmbeddedFile.Exists(filename));
#endif
        }
   internal FullFileSpecification(
 EmbeddedFile embeddedFile,
 string filename
 )
       : this(embeddedFile.Document, filename)
   {
       EmbeddedFile = embeddedFile;
   }
        public void TestImportAMC()
        {
            AMCParser parser = new AMCParser();

            using (var strm = EmbeddedFile.GetStream("MHGameWork.TheWizards.Tests.Features.Simulation.Animation.Files.TestAnimation01.amc"))
            {
                parser.ImportAMC(strm);
            }
        }
Esempio n. 9
0
        private GraphNode ParseAlignment(Align align, EmbeddedFile file)
        {
            if (align.boundary == 4)
            {
                file.AlignToDwordBoundary();
                return(new GraphNode("DWORD align", NodeType.Empty, file.Position - align.boundary, align.boundary));
            }

            throw new NotImplementedException();
        }
Esempio n. 10
0
        public System.IO.Stream GetSkin()
        {
            EmbeddedFile ef = XSimFieldLibraryImpl.sCurrentLib.GetFileByID(this.GUIDisplay);

            System.IO.MemoryStream ms = null;

            ms = new System.IO.MemoryStream(ef.Data);

            return(ms);
        }
        public void TestImportAMCCreateRelativeMatrices()
        {
            AMCParser parser = new AMCParser();

            using (var strm = EmbeddedFile.GetStream("MHGameWork.TheWizards.Tests.Features.Simulation.Animation.Files.TestAnimation02.amc"))
            {
                parser.ImportAMC(strm);
            }

            // Import skeleton
            var asfParser = new ASFParser();

            using (var strm = EmbeddedFile.GetStream("MHGameWork.TheWizards.Tests.Features.Simulation.Animation.Files.TestSkeleton02.asf"))
            {
                asfParser.ImportASF(strm);
            }
            var skeleton = asfParser.ImportSkeleton();


            var game = new DX11Game();
            var vis  = new SkeletonVisualizer();

            for (int i = 0; i < skeleton.Joints.Count; i++)
            {
                skeleton.Joints[i].RelativeMatrix = Matrix.Identity;
            }

            float time  = 0;
            float speed = 1;

            game.GameLoopEvent += delegate
            {
                game.LineManager3D.DrawGroundShadows = true;

                time += game.Elapsed;
                var sampleNum = (int)(time * 120 * speed) % parser.Samples.Count;

                for (int i = 0; i < parser.Samples[sampleNum].Segments.Count; i++)
                {
                    var seg = parser.Samples[sampleNum].Segments[i];

                    var asfJoint = asfParser.Joints.Find(j => j.name == seg.JointName);
                    var joint    = skeleton.Joints.Find(j => j.Name == seg.JointName);

                    Matrix relativeMat = parser.CalculateRelativeMatrix(seg, asfJoint);

                    joint.RelativeMatrix = relativeMat;
                }
                skeleton.UpdateAbsoluteMatrices();

                vis.VisualizeSkeleton(game, skeleton, new Vector3(4, 0, 4));
            };

            game.Run();
        }
Esempio n. 12
0
 private void EvaluateDataFile(FileSpecification dataFile)
 {
     if (dataFile is FullFileSpecification)
     {
         EmbeddedFile embeddedFile = ((FullFileSpecification)dataFile).EmbeddedFile;
         if (embeddedFile != null)
         {
             ExportAttachment(embeddedFile.Data, dataFile.Path);
         }
     }
 }
Esempio n. 13
0
 public Screen(Page page, SKRect box, String text, String mediaPath, String mimeType)
     : this(page, box, text, new MediaRendition(
                new MediaClipData(
                    FileSpecification.Get(
                        EmbeddedFile.Get(page.Document, mediaPath),
                        System.IO.Path.GetFileName(mediaPath)
                        ),
                    mimeType
                    )
                )
            )
 {
 }
        public static void Run(string outputPdfPath)
        {
            // Create a PDF Document
            Document document = new Document
            {
                Creator = "Aes256BitEncryption",
                Author  = "ceTe Software",
                Title   = "AES 256 Bit Encrypted Document"
            };

            // Create a page to add to the document
            Page page = new Page(PageSize.Letter, PageOrientation.Portrait, 54.0f);

            // Create a Label to add to the page
            string text  = "Hello ASPX C# World...\nFrom DynamicPDF Generator for .NET\nDynamicPDF.com";
            Label  label = new Label(text, 0, 0, 504, 100, Font.Helvetica, 18, TextAlign.Center);

            // Add label to page
            page.Elements.Add(label);

            // Add page to document
            document.Pages.Add(page);

            // Create an instance of EmbeddedFile
            EmbeddedFile embeddedFile = new EmbeddedFile(Util.GetResourcePath("PDFs/DocumentA.pdf"));

            // Add the embeddedFile to the EmbeddedFileList of the document public class
            document.EmbeddedFiles.Add(embeddedFile);

            // Set the PageMode to the ShowAttachments
            document.InitialPageMode = PageMode.ShowAttachments;

            // Create AES 256 bit security object
            Aes256Security security = new Aes256Security("password")
            {
                // Set DocumentComponents property to OnlyFileAttachments
                DocumentComponents = EncryptDocumentComponents.OnlyFileAttachments
            };

            // Add the security object to the document
            document.Security = security;

            // Outputs the document to the current web page
            document.Draw(outputPdfPath);
        }
        public void TestImportSkeletonFromASF()
        {
            var parser = new ASFParser();


            var root = new ASFJoint();

            parser.RootJoint = root;

            var child1 = new ASFJoint();

            child1.length    = 4;
            child1.direction = MathHelper.Up;
            root.children.Add(child1);

            var child2 = new ASFJoint();

            child2.direction = MathHelper.Up;
            child1.children.Add(child2);

            var skeleton1 = parser.ImportSkeleton();

            skeleton1.UpdateAbsoluteMatrices();

            using (var strm = EmbeddedFile.GetStream("MHGameWork.TheWizards.Tests.Features.Simulation.Animation.Files.TestSkeleton01.asf"))
            {
                parser.ImportASF(strm);
            }
            var skeleton2 = parser.ImportSkeleton();

            skeleton2.UpdateAbsoluteMatrices();

            var game = new DX11Game();
            var vis  = new SkeletonVisualizer();

            game.GameLoopEvent += delegate
            {
                vis.VisualizeSkeleton(game, skeleton1, new Vector3(4, 0, 4));
                vis.VisualizeSkeleton(game, skeleton2, new Vector3(11, 0, 11));
            };

            game.Run();
        }
        public void TestImportASF()
        {
            var parser = new ASFParser();

            using (var strm = EmbeddedFile.GetStream("MHGameWork.TheWizards.Tests.Features.Simulation.Animation.Files.TestSkeleton01.asf"))
            {
                parser.ImportASF(strm);
            }

            var game = new DX11Game();


            game.GameLoopEvent += delegate
            {
                drawASFJoint(game, parser.RootJoint, new Vector3(4, 0, 4));
            };

            game.Run();
        }
Esempio n. 17
0
        public FileGraph ApplyFilterToFile(EmbeddedFile file, string filterName,
                                           IParserOutput output)
        {
            if (file == null || filterName == null || output == null)
            {
                throw new ArgumentException("Invalid parameters specified.");
            }

            // lookup the filter with the specified name
            DataFileDef filter = m_mapping.GetFilterByName(filterName);

            if (filter == null)
            {
                output.HandleFatalError("The specified filter does not exist.");
            }

            FileGraph graph = new FileGraph(file.FileId);

            try
            {
                // open the input file
                file.PrepareFileForReading();

                // create a root node in the graph
                graph.RootNode = new GraphNode("Root node", NodeType.Complex, file.Position);
                foreach (object filterObject in filter.Items)
                {
                    DecodeEntry(graph.RootNode, filterObject, output, file);
                }
                graph.RootNode.FilePositionEnd = file.Position;

                graph.UpdateEndPositionOfNodes();
            }
            catch (Exception ex)
            {
                output.HandleFatalError("Unexpected exception: " + ex.Message);
            }
            finally
            {
                file.FileReadingComplete();
            }
            return(graph);
        }
Esempio n. 18
0
        public static void Run(string outputPdfPath)
        {
            // Create a PDF Document
            Document document = new Document
            {
                Creator = "PackagePdf",
                Author  = "ceTe Software",
                Title   = "Package Pdf"
            };

            // FileStreams used for creating the instance of EmbeddedFile
            FileStream fileStream1 = new FileStream(Util.GetResourcePath("Images/DPDFLogo.png"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            FileStream fileStream2 = new FileStream(Util.GetResourcePath("Data/HelloWorldExcel.xls"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            // byte array of the file by reading the file.
            byte[] filebyte = new byte[fileStream2.Length];
            fileStream2.Read(filebyte, 0, filebyte.Length);

            // Created 3 instances of EmbeddedFile using all the available constructors.
            EmbeddedFile embeddedFile1 = new EmbeddedFile(Util.GetResourcePath("PDFs/DocumentA.pdf"));
            EmbeddedFile embeddedFile2 = new EmbeddedFile(fileStream1, "DPDFLogo.png", DateTime.Now);
            EmbeddedFile embeddedFile3 = new EmbeddedFile(filebyte, "HelloWorldExcel.xls", DateTime.Now);

            // Added the embeddedFiles to the EmbeddedFileList of the document public class.
            document.EmbeddedFiles.Add(embeddedFile1);
            document.EmbeddedFiles.Add(embeddedFile2);
            document.EmbeddedFiles.Add(embeddedFile3);

            // Create a Page and add it to the document
            Page page = new Page();

            document.Pages.Add(page);

            // Create a Document Package with Attachment Layout Detailed
            document.Package = new DocumentPackage(AttachmentLayout.Detailed);

            // Add a label to the page
            page.Elements.Add(new Label("This is the cover page for a package PDF", 0, 0, 512, 40, Font.Helvetica, 24, TextAlign.Center));

            // Save the PDF document
            document.Draw(outputPdfPath);
        }
Esempio n. 19
0
        private void ApplyFilterToFile()
        {
            if (cbFilters.SelectedIndex >= 0 && cbFiles.SelectedIndex >= 0)
            {
                uint   fileId     = UInt32.Parse(cbFiles.SelectedItem.ToString(), NumberStyles.HexNumber);
                string filterName = cbFilters.SelectedItem.ToString();

                m_currentFile = DataProvider.Instance.PortalDatReader.LocateFile(fileId);
                FileGraph graph = m_parser.ApplyFilterToFile(m_currentFile, filterName, this);
                if (graph != null)
                {
                    ShowGraph(graph);
                    ShowFileContents();
                }
            }
            else
            {
                // clear the display
            }
        }
Esempio n. 20
0
        public ShaderResourceView LoadTexture(ITexture tex)
        {
            TextureInfo ret;

            if (!cache.TryGetValue(tex, out ret))
            {
                var data = tex.GetCoreData();
                //var p =TextureCreationParameters.Default;

                Texture2D tx;

                switch (data.StorageType)
                {
                case TextureCoreData.TextureStorageType.Disk:
                    //ret = Texture2D.FromFile(game.GraphicsDevice, data.DiskFilePath,p);
                    tx = Texture2D.FromFile(game.Device, data.DiskFilePath);
                    break;

                case TextureCoreData.TextureStorageType.Assembly:
                    //ret = Texture2D.FromFile(game.GraphicsDevice,
                    //                         EmbeddedFile.GetStream(data.Assembly, data.AssemblyResourceName, null),p);
                    using (var strm = EmbeddedFile.GetStream(data.Assembly, data.AssemblyResourceName, null))
                        tx = Texture2D.FromStream(game.Device, strm, (int)strm.Length);

                    break;

                default:
                    throw new InvalidOperationException();
                }

                ret = new TextureInfo
                {
                    Texture2D    = tx,
                    ResourceView = new ShaderResourceView(game.Device, tx)
                };

                cache[tex] = ret;
            }
            return(ret.ResourceView);
        }
        private void LoadShader(EffectPool pool)
        {
            //
            // Load the shader and set the material properties
            //

            if (shader != null)
            {
                shader.Dispose();
            }

            System.IO.Stream strm = EmbeddedFile.GetStreamFullPath(
                "MHGameWork.TheWizards.Rendering.Files.DefaultModelShader.fx",
                game.EngineFiles.DebugFilesDirectory + "/DefaultModelShader.fx");

            shader = BasicShader.LoadFromFXFile(game, strm, pool);
            //Shader = BasicShader.LoadFromFXFile( game, new GameFile( shaderFilename ), pool );

            LoadParameters();
            LoadTechniques();

            SetTechniqueType(TechniqueType.Colored);
        }
Esempio n. 22
0
        public Texture2D LoadTexture(ITexture tex)
        {
            Texture2D ret;

            if (!cache.TryGetValue(tex, out ret))
            {
                var data = tex.GetCoreData();
                var p    = TextureCreationParameters.Default;

                switch (data.StorageType)
                {
                case TextureCoreData.TextureStorageType.Disk:
                    ret = Texture2D.FromFile(game.GraphicsDevice, data.DiskFilePath, p);
                    break;

                case TextureCoreData.TextureStorageType.Assembly:
                    ret = Texture2D.FromFile(game.GraphicsDevice,
                                             EmbeddedFile.GetStream(data.Assembly, data.AssemblyResourceName, null), p);
                    break;
                }
                cache[tex] = ret;
            }
            return(ret);
        }
Esempio n. 23
0
        public void Initialize(IXNAGame _game)
        {
            game = _game;

            checkerTexture = Texture2D.FromFile(game.GraphicsDevice,
                                                EmbeddedFile.GetStream(
                                                    "MHGameWork.TheWizards.Rendering.Files.Checker.png", "Checker.png"));


            baseShader                = new DefaultModelShader(_game, new EffectPool());
            baseShader.LightColor     = new Vector3(0.9f, 0.9f, 0.9f);
            baseShader.AmbientColor   = new Vector4(0.15f, 0.15f, 0.15f, 1f);
            baseShader.Shininess      = 100;
            baseShader.SpecularColor  = Color.Black.ToVector4();
            baseShader.LightDirection = Vector3.Normalize(new Vector3(1, -5, 1));
            baseShader.DiffuseTexture = checkerTexture;



            for (int i = 0; i < renderDatas.Count; i++)
            {
                initMeshRenderData(renderDatas[i]);
            }
        }
Esempio n. 24
0
        private void DecodeEntry(GraphNode parentNode, object newSubObject, IParserOutput output, EmbeddedFile file)
        {
            // decode the node and add it to the parent:

            // first determine the exact type of node
            if (newSubObject is Field)
            {
                parentNode.Add(ParseField(newSubObject as Field, file));
            }
            else if (newSubObject is Align)
            {
                // align to the specified boundary
                parentNode.Add(ParseAlignment(newSubObject as Align, file));
            }
            else if (newSubObject is NamedType)
            {
                GraphNode complexNode = parentNode.Add(ParseNamedType(newSubObject as NamedType, file));

                // look up the specified type
                TypeDef definition = m_mapping.GetTypeDefByName((newSubObject as NamedType).TypeName);
                foreach (object subEbtry in definition.Items)
                {
                    DecodeEntry(complexNode, subEbtry, output, file);
                }
            }
            else if (newSubObject is Vector)
            {
                GraphNode vectorNode = parentNode.Add(ParseVector(newSubObject as Vector, file));

                // determine the length of the vector
                // this is done by examining the contents of the 'length' field
                // for now, we assume that all lengths are stored in a sister field of the vector, that
                // has appeared previously
                string    indexFieldName = (newSubObject as Vector).Length;
                GraphNode amountNode     = parentNode.GetNamedField(indexFieldName);
                if (amountNode == null)
                {
                    throw new ArgumentException(string.Format("Unable to find named field {0}", indexFieldName));
                }

                int length = Convert.ToInt32(amountNode.Value);

                // parse for the specified amount of times
                for (int i = 0; i < length; i++)
                {
                    DecodeEntry(vectorNode, (newSubObject as Vector).Item, output, file);
                }
            }
            else
            {
                throw new Exception("Unknown type of filter object");
            }
        }
        /**
          <see cref="GetEmbeddedFile(PdfName)"/>
        */
        private void SetEmbeddedFile(
      PdfName key,
      EmbeddedFile value
      )
        {
            PdfDictionary embeddedFilesObject = (PdfDictionary)BaseDictionary[PdfName.EF];
              if(embeddedFilesObject == null)
              {BaseDictionary[PdfName.EF] = embeddedFilesObject = new PdfDictionary();}

              embeddedFilesObject[key] = value.BaseObject;
        }
Esempio n. 26
0
 private GraphNode ParseVector(Vector vector, EmbeddedFile file)
 {
     return(new GraphNode(vector.Name, NodeType.Vector, file.Position));
 }
Esempio n. 27
0
        public void Initialize(IXNAGame _game)
        {
            game = _game;
            //get the sizes of the backbuffer, in order to have matching render targets
            int backBufferWidth  = _game.GraphicsDevice.PresentationParameters.BackBufferWidth;
            int backBufferHeight = _game.GraphicsDevice.PresentationParameters.BackBufferHeight;


            initializeDeferredRendering(_game, backBufferWidth, backBufferHeight);

            initializeDeferredShading(_game, backBufferWidth, backBufferHeight);


            ambientOcclusionRT = new RenderTarget2D(_game.GraphicsDevice, backBufferWidth,
                                                    backBufferHeight, 1, SurfaceFormat.Color);     //TODO: use better channel here
            blurRT = new RenderTarget2D(_game.GraphicsDevice, backBufferWidth,
                                        backBufferHeight, 1, SurfaceFormat.Color);                 //TODO: use better channel here



            downsampleSize        = new Point(backBufferWidth / 2, backBufferHeight / 2);
            downsampleHalfPixel.X = 0.5f / downsampleSize.X;
            downsampleHalfPixel.Y = 0.5f / downsampleSize.Y;
            downsampleRT          = new RenderTarget2D(_game.GraphicsDevice, downsampleSize.X,
                                                       downsampleSize.Y, 1, SurfaceFormat.Color);
            downsampleBlurYRT = new RenderTarget2D(_game.GraphicsDevice, downsampleSize.X,
                                                   downsampleSize.Y, 1, SurfaceFormat.Color);



            deferredShader = loadShader("DeferredShader.fx");



            ambientOcclusionShader = loadShader("AmbientOcclusion.fx");

            blurShader = loadShader("Blur.fx");

            downsampleShader = loadShader("Downsample.fx");


            fullScreenQuad           = new FullScreenQuad(GraphicsDevice);
            tangentVertexDeclaration = TangentVertexExtensions.CreateVertexDeclaration(game);


            mesh        = merchantsHouseMesh;
            texturePool = new Rendering.TexturePool();

            texturePool.Initialize(game);
            meshPartPool = new MeshPartPool();
            meshPartPool.Initialize(game);

            boxTexture  = Texture2D.FromFile(GraphicsDevice, new FileStream(woodPlanksBarePath, FileMode.Open, FileAccess.Read, FileShare.Read));
            halfPixel.X = 0.5f / GraphicsDevice.PresentationParameters.BackBufferWidth;
            halfPixel.Y = 0.5f / GraphicsDevice.PresentationParameters.BackBufferHeight;



            checkerTexture = Texture2D.FromFile(game.GraphicsDevice,
                                                EmbeddedFile.GetStream(
                                                    "MHGameWork.TheWizards.Rendering.Files.Checker.png", "Checker.png"));


            randomNormalsTexture = Texture2D.FromFile(game.GraphicsDevice,
                                                      EmbeddedFile.GetStream(
                                                          "MHGameWork.TheWizards.Rendering.Deferred.Files.RandomNormals.png", "RandomNormals.png"));

            initializeToneMap();
        }
Esempio n. 28
0
        private void Populate(Document document)
        {
            Page page = new Page(document);

            document.Pages.Add(page);

            PrimitiveComposer        composer = new PrimitiveComposer(page);
            fonts::StandardType1Font font     = new fonts::StandardType1Font(document, fonts::StandardType1Font.FamilyEnum.Courier, true, false);

            composer.SetFont(font, 12);

            // Sticky note.
            composer.ShowText("Sticky note annotation:", new SKPoint(35, 35));
            new StickyNote(page, new SKPoint(50, 50), "Text of the Sticky note annotation")
            {
                IconType = StickyNote.IconTypeEnum.Note,
                Color    = DeviceRGBColor.Get(SKColors.Yellow),
                Popup    = new Popup(
                    page,
                    SKRect.Create(200, 25, 200, 75),
                    "Text of the Popup annotation (this text won't be visible as associating popups to markup annotations overrides the former's properties with the latter's)"
                    ),
                Author  = "Stefano",
                Subject = "Sticky note",
                IsOpen  = true
            };
            new StickyNote(page, new SKPoint(80, 50), "Text of the Help sticky note annotation")
            {
                IconType = StickyNote.IconTypeEnum.Help,
                Color    = DeviceRGBColor.Get(SKColors.Pink),
                Author   = "Stefano",
                Subject  = "Sticky note",
                Popup    = new Popup(
                    page,
                    SKRect.Create(400, 25, 200, 75),
                    "Text of the Popup annotation (this text won't be visible as associating popups to markup annotations overrides the former's properties with the latter's)"
                    )
            };
            new StickyNote(page, new SKPoint(110, 50), "Text of the Comment sticky note annotation")
            {
                IconType = StickyNote.IconTypeEnum.Comment,
                Color    = DeviceRGBColor.Get(SKColors.Green),
                Author   = "Stefano",
                Subject  = "Sticky note"
            };
            new StickyNote(page, new SKPoint(140, 50), "Text of the Key sticky note annotation")
            {
                IconType = StickyNote.IconTypeEnum.Key,
                Color    = DeviceRGBColor.Get(SKColors.Blue),
                Author   = "Stefano",
                Subject  = "Sticky note"
            };

            // Callout.
            composer.ShowText("Callout note annotation:", new SKPoint(35, 85));
            new FreeText(page, SKRect.Create(250, 90, 150, 70), "Text of the Callout note annotation")
            {
                Line = new FreeText.CalloutLine(
                    page,
                    new SKPoint(100, 100),
                    new SKPoint(150, 125),
                    new SKPoint(250, 125)
                    ),
                Type         = FreeText.TypeEnum.Callout,
                LineEndStyle = LineEndStyleEnum.OpenArrow,
                Border       = new Border(1),
                Color        = DeviceRGBColor.Get(SKColors.Yellow)
            };

            // File attachment.
            composer.ShowText("File attachment annotation:", new SKPoint(35, 135));
            new FileAttachment(
                page,
                SKRect.Create(50, 150, 15, 20),
                "Text of the File attachment annotation",
                FileSpecification.Get(
                    EmbeddedFile.Get(document, GetResourcePath("images" + Path.DirectorySeparatorChar + "gnu.jpg")),
                    "happyGNU.jpg")
                )
            {
                IconType = FileAttachment.IconTypeEnum.PaperClip,
                Author   = "Stefano",
                Subject  = "File attachment"
            };

            composer.ShowText("Line annotation:", new SKPoint(35, 185));
            {
                composer.BeginLocalState();
                composer.SetFont(font, 10);

                // Arrow line.
                composer.ShowText("Arrow:", new SKPoint(50, 200));
                new Line(
                    page,
                    new SKPoint(50, 260),
                    new SKPoint(200, 210),
                    "Text of the Arrow line annotation",
                    DeviceRGBColor.Get(SKColors.Black))
                {
                    StartStyle     = LineEndStyleEnum.Circle,
                    EndStyle       = LineEndStyleEnum.ClosedArrow,
                    CaptionVisible = true,
                    FillColor      = DeviceRGBColor.Get(SKColors.Green),
                    Author         = "Stefano",
                    Subject        = "Arrow line"
                };

                // Dimension line.
                composer.ShowText("Dimension:", new SKPoint(300, 200));
                new Line(
                    page,
                    new SKPoint(300, 220),
                    new SKPoint(500, 220),
                    "Text of the Dimension line annotation",
                    DeviceRGBColor.Get(SKColors.Blue)
                    )
                {
                    LeaderLineLength          = 20,
                    LeaderLineExtensionLength = 10,
                    StartStyle     = LineEndStyleEnum.OpenArrow,
                    EndStyle       = LineEndStyleEnum.OpenArrow,
                    Border         = new Border(1),
                    CaptionVisible = true,
                    Author         = "Stefano",
                    Subject        = "Dimension line"
                };

                composer.End();
            }

            var path = new SKPath();

            path.MoveTo(new SKPoint(50, 320));
            path.LineTo(new SKPoint(70, 305));
            path.LineTo(new SKPoint(110, 335));
            path.LineTo(new SKPoint(130, 320));
            path.LineTo(new SKPoint(110, 305));
            path.LineTo(new SKPoint(70, 335));
            path.LineTo(new SKPoint(50, 320));
            // Scribble.
            composer.ShowText("Scribble annotation:", new SKPoint(35, 285));
            new Scribble(
                page,
                new List <SKPath> {
                path
            },
                "Text of the Scribble annotation",
                DeviceRGBColor.Get(SKColors.Orange))
            {
                Border  = new Border(1, new LineDash(new double[] { 5, 2, 2, 2 })),
                Author  = "Stefano",
                Subject = "Scribble"
            };

            // Rectangle.
            composer.ShowText("Rectangle annotation:", new SKPoint(35, 350));
            new PdfClown.Documents.Interaction.Annotations.Rectangle(
                page,
                SKRect.Create(50, 370, 100, 30),
                "Text of the Rectangle annotation")
            {
                Color   = DeviceRGBColor.Get(SKColors.Red),
                Border  = new Border(1, new LineDash(new double[] { 5 })),
                Author  = "Stefano",
                Subject = "Rectangle",
                Popup   = new Popup(
                    page,
                    SKRect.Create(200, 325, 200, 75),
                    "Text of the Popup annotation (this text won't be visible as associating popups to markup annotations overrides the former's properties with the latter's)"
                    )
            };

            // Ellipse.
            composer.ShowText("Ellipse annotation:", new SKPoint(35, 415));
            new Ellipse(
                page,
                SKRect.Create(50, 440, 100, 30),
                "Text of the Ellipse annotation")
            {
                BorderEffect = new BorderEffect(BorderEffect.TypeEnum.Cloudy, 1),
                FillColor    = DeviceRGBColor.Get(SKColors.Cyan),
                Color        = DeviceRGBColor.Get(SKColors.Black),
                Author       = "Stefano",
                Subject      = "Ellipse"
            };

            // Rubber stamp.
            composer.ShowText("Rubber stamp annotations:", new SKPoint(35, 505));
            {
                fonts::Font stampFont = fonts::Font.Get(document, GetResourcePath("fonts" + Path.DirectorySeparatorChar + "TravelingTypewriter.otf"));
                new Stamp(
                    page,
                    new SKPoint(75, 570),
                    "This is a round custom stamp",
                    new StampAppearanceBuilder(document, StampAppearanceBuilder.TypeEnum.Round, "Done", 50, stampFont)
                    .Build()
                    )
                {
                    Rotation = -10,
                    Author   = "Stefano",
                    Subject  = "Custom stamp"
                };

                new Stamp(
                    page,
                    new SKPoint(210, 570),
                    "This is a squared (and round-cornered) custom stamp",
                    new StampAppearanceBuilder(document, StampAppearanceBuilder.TypeEnum.Squared, "Classified", 150, stampFont)
                {
                    Color = DeviceRGBColor.Get(SKColors.Orange)
                }.Build()
                    )
                {
                    Rotation = 15,
                    Author   = "Stefano",
                    Subject  = "Custom stamp"
                };

                fonts::Font stampFont2 = fonts::Font.Get(document, GetResourcePath("fonts" + Path.DirectorySeparatorChar + "MgOpenCanonicaRegular.ttf"));
                new Stamp(
                    page,
                    new SKPoint(350, 570),
                    "This is a striped custom stamp",
                    new StampAppearanceBuilder(document, StampAppearanceBuilder.TypeEnum.Striped, "Out of stock", 100, stampFont2)
                {
                    Color = DeviceRGBColor.Get(SKColors.Gray)
                }.Build()
                    )
                {
                    Rotation = 90,
                    Author   = "Stefano",
                    Subject  = "Custom stamp"
                };

                // Define the standard stamps template path!

                /*
                 * NOTE: The PDF specification defines several stamps (aka "standard stamps") whose rendering
                 * depends on the support of viewer applications. As such support isn't guaranteed, PDF Clown
                 * offers smooth, ready-to-use embedding of these stamps through the StampPath property of the
                 * document configuration: you can decide to point to the stamps directory of your Acrobat
                 * installation (e.g., in my GNU/Linux system it's located in
                 * "/opt/Adobe/Reader9/Reader/intellinux/plug_ins/Annotations/Stamps/ENU") or to the
                 * collection included in this distribution (std-stamps.pdf).
                 */
                document.Configuration.StampPath = GetResourcePath("../../pkg/templates/std-stamps.pdf");

                // Add a standard stamp, rotating it 15 degrees counterclockwise!
                new Stamp(
                    page,
                    new SKPoint(485, 515),
                    null, // Default size is natural size.
                    "This is 'Confidential', a standard stamp",
                    StandardStampEnum.Confidential)
                {
                    Rotation = 15,
                    Author   = "Stefano",
                    Subject  = "Standard stamp"
                };

                // Add a standard stamp, without rotation!
                new Stamp(
                    page,
                    new SKPoint(485, 580),
                    null, // Default size is natural size.
                    "This is 'SBApproved', a standard stamp",
                    StandardStampEnum.BusinessApproved)
                {
                    Author  = "Stefano",
                    Subject = "Standard stamp"
                };

                // Add a standard stamp, rotating it 10 degrees clockwise!
                new Stamp(
                    page,
                    new SKPoint(485, 635),
                    new SKSize(0, 40), // This scales the width proportionally to the 40-unit height (you can obviously do also the opposite, defining only the width).
                    "This is 'SHSignHere', a standard stamp",
                    StandardStampEnum.SignHere)
                {
                    Rotation = -10,
                    Author   = "Stefano",
                    Subject  = "Standard stamp"
                };
            }

            composer.ShowText("Text markup annotations:", new SKPoint(35, 650));
            {
                composer.BeginLocalState();
                composer.SetFont(font, 8);

                new TextMarkup(
                    page,
                    composer.ShowText("Highlight annotation", new SKPoint(35, 680)),
                    "Text of the Highlight annotation",
                    TextMarkup.MarkupTypeEnum.Highlight)
                {
                    Author  = "Stefano",
                    Subject = "An highlight text markup!"
                };
                new TextMarkup(
                    page,
                    composer.ShowText("Highlight annotation 2", new SKPoint(35, 695)).Inflate(0, 1),
                    "Text of the Highlight annotation 2",
                    TextMarkup.MarkupTypeEnum.Highlight)
                {
                    Color = DeviceRGBColor.Get(SKColors.Magenta)
                };
                new TextMarkup(
                    page,
                    composer.ShowText("Highlight annotation 3", new SKPoint(35, 710)).Inflate(0, 2),
                    "Text of the Highlight annotation 3",
                    TextMarkup.MarkupTypeEnum.Highlight)
                {
                    Color = DeviceRGBColor.Get(SKColors.Red)
                };

                new TextMarkup(
                    page,
                    composer.ShowText("Squiggly annotation", new SKPoint(180, 680)),
                    "Text of the Squiggly annotation",
                    TextMarkup.MarkupTypeEnum.Squiggly);
                new TextMarkup(
                    page,
                    composer.ShowText("Squiggly annotation 2", new SKPoint(180, 695)).Inflate(0, 2.5f),
                    "Text of the Squiggly annotation 2",
                    TextMarkup.MarkupTypeEnum.Squiggly)
                {
                    Color = DeviceRGBColor.Get(SKColors.Orange)
                };
                new TextMarkup(
                    page,
                    composer.ShowText("Squiggly annotation 3", new SKPoint(180, 710)).Inflate(0, 3),
                    "Text of the Squiggly annotation 3",
                    TextMarkup.MarkupTypeEnum.Squiggly)
                {
                    Color = DeviceRGBColor.Get(SKColors.Pink)
                };

                new TextMarkup(
                    page,
                    composer.ShowText("Underline annotation", new SKPoint(320, 680)),
                    "Text of the Underline annotation",
                    TextMarkup.MarkupTypeEnum.Underline
                    );
                new TextMarkup(
                    page,
                    composer.ShowText("Underline annotation 2", new SKPoint(320, 695)).Inflate(0, 2.5f),
                    "Text of the Underline annotation 2",
                    TextMarkup.MarkupTypeEnum.Underline
                    )
                {
                    Color = DeviceRGBColor.Get(SKColors.Orange)
                };
                new TextMarkup(
                    page,
                    composer.ShowText("Underline annotation 3", new SKPoint(320, 710)).Inflate(0, 3),
                    "Text of the Underline annotation 3",
                    TextMarkup.MarkupTypeEnum.Underline
                    )
                {
                    Color = DeviceRGBColor.Get(SKColors.Green)
                };

                new TextMarkup(
                    page,
                    composer.ShowText("StrikeOut annotation", new SKPoint(455, 680)),
                    "Text of the StrikeOut annotation",
                    TextMarkup.MarkupTypeEnum.StrikeOut
                    );
                new TextMarkup(
                    page,
                    composer.ShowText("StrikeOut annotation 2", new SKPoint(455, 695)).Inflate(0, 2.5f),
                    "Text of the StrikeOut annotation 2",
                    TextMarkup.MarkupTypeEnum.StrikeOut
                    )
                {
                    Color = DeviceRGBColor.Get(SKColors.Orange)
                };
                new TextMarkup(
                    page,
                    composer.ShowText("StrikeOut annotation 3", new SKPoint(455, 710)).Inflate(0, 3),
                    "Text of the StrikeOut annotation 3",
                    TextMarkup.MarkupTypeEnum.StrikeOut
                    )
                {
                    Color = DeviceRGBColor.Get(SKColors.Green)
                };

                composer.End();
            }
            composer.Flush();
        }
Esempio n. 29
0
    public Example_78()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_78.pdf", FileMode.Create)));

        Font f1 = new Font(pdf, CoreFont.HELVETICA_BOLD);

        Font f2 = new Font(pdf, new FileStream(
                               "fonts/OpenSans/OpenSans-Regular.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read),
                           Font.STREAM);

        String       fileName = "linux-logo.png";
        EmbeddedFile file1    = new EmbeddedFile(
            pdf,
            fileName,
            new FileStream("images/" + fileName, FileMode.Open, FileAccess.Read),
            false);         // Don't compress images.

        fileName = "Example_02.cs";
        EmbeddedFile file2 = new EmbeddedFile(
            pdf,
            fileName,
            new FileStream(fileName, FileMode.Open, FileAccess.Read),
            true);          // Compress text files.

        Page page = new Page(pdf, Letter.PORTRAIT);

        f1.SetSize(10f);

        FileAttachment attachment = new FileAttachment(pdf, file1);

        attachment.SetLocation(0f, 0f);
        attachment.SetIconPushPin();
        attachment.SetTitle("Attached File: " + file1.GetFileName());
        attachment.SetDescription(
            "Right mouse click or double click on the icon to save the attached file.");
        float[] point = attachment.DrawOn(page);

        attachment = new FileAttachment(pdf, file2);
        attachment.SetLocation(0f, point[1]);
        attachment.SetIconPaperclip();
        attachment.SetTitle("Attached File: " + file2.GetFileName());
        attachment.SetDescription(
            "Right mouse click or double click on the icon to save the attached file.");
        point = attachment.DrawOn(page);


        CheckBox checkbox = new CheckBox(f1, "Hello");

        checkbox.SetLocation(0f, point[1]);
        checkbox.SetCheckmark(Color.blue);
        checkbox.Check(Mark.CHECK);
        point = checkbox.DrawOn(page);

        checkbox = new CheckBox(f1, "Hello");
        checkbox.SetLocation(0.0, point[1]);
        checkbox.SetCheckmark(Color.blue);
        checkbox.Check(Mark.X);
        point = checkbox.DrawOn(page);

        Box box = new Box();

        box.SetLocation(0f, point[1]);
        box.SetSize(20f, 20f);
        point = box.DrawOn(page);

        RadioButton radiobutton = new RadioButton(f1, "Yes");

        radiobutton.SetLocation(0f, point[1]);
        radiobutton.SetURIAction("http://pdfjet.com");
        radiobutton.Select(true);
        point = radiobutton.DrawOn(page);

        QRCode qr = new QRCode(
            "https://kazuhikoarase.github.io",
            ErrorCorrectLevel.L);       // Low

        qr.SetModuleLength(3f);
        qr.SetLocation(0f, point[1]);
        point = qr.DrawOn(page);

        Dictionary <String, Int32> colors = new Dictionary <String, Int32>();

        colors["brown"] = Color.brown;
        colors["fox"]   = Color.maroon;
        colors["lazy"]  = Color.darkolivegreen;
        colors["jumps"] = Color.darkviolet;
        colors["dog"]   = Color.chocolate;
        colors["sight"] = Color.blue;

        StringBuilder buf = new StringBuilder();

        buf.Append("The quick brown fox jumps over the lazy dog. What a sight!\n\n");

        TextBox textbox = new TextBox(f1, buf.ToString());

        textbox.SetLocation(0f, point[1]);
        // textbox.SetWidth(f1.StringWidth(buf.ToString()));
        textbox.SetBgColor(Color.whitesmoke);
        textbox.SetTextColors(colors);
        point = textbox.DrawOn(page);


        buf = new StringBuilder();
        buf.Append("Calculus, originally called infinitesimal calculus or \"the calculus of infinitesimals\", ");
        buf.Append("is the mathematical study of continuous change, in the same way that geometry is the ");
        buf.Append("study of shape and algebra is the study of generalizations of arithmetic operations. ");
        buf.Append("It has two major branches, differential calculus and integral calculus; ");
        buf.Append("the former concerns instantaneous rates of change, and the slopes of curves, ");
        buf.Append("while integral calculus concerns accumulation of quantities, and areas under or between ");
        buf.Append("curves. These two branches are related to each other by the fundamental theorem of calculus, ");
        buf.Append("and they make use of the fundamental notions of convergence of infinite sequences and ");
        buf.Append("infinite series to a well-defined limit.");

        TextBlock textBlock = new TextBlock(f1);

        textBlock.SetText(buf.ToString());
        textBlock.SetLocation(0f, point[1]);
        // textBlock.SetWidth(50f);
        point = textBlock.DrawOn(page);

        BarCode code = new BarCode(BarCode.CODE128, "Hello, World!");

        code.SetLocation(0f, point[1]);
        code.SetModuleLength(0.75f);
        code.SetFont(f1);
        point = code.DrawOn(page);

        buf = new StringBuilder();
        buf.Append("Using another font ...\n\nThis is a test.");
        textbox = new TextBox(f2, buf.ToString());
        textbox.SetLocation(0f, point[1]);
        point = textbox.DrawOn(page);

        code = new BarCode(BarCode.CODE128, "G86513JVW0C");
        code.SetLocation(0f, point[1]);
        code.SetModuleLength(0.75f);
        code.SetDirection(BarCode.TOP_TO_BOTTOM);
        code.SetFont(f1);
        point = code.DrawOn(page);

        buf = new StringBuilder();
        StreamReader reader = new StreamReader(
            new FileStream("Example_12.cs", FileMode.Open));
        String line = null;

        while ((line = reader.ReadLine()) != null)
        {
            buf.Append(line);
            // Both CR and LF are required by the scanner!
            buf.Append((char)13);
            buf.Append((char)10);
        }

        BarCode2D code2D = new BarCode2D(buf.ToString());

        code2D.SetModuleWidth(0.5f);
        code2D.SetLocation(0f, point[1]);
        point = code2D.DrawOn(page);

        pdf.Complete();
    }
Esempio n. 30
0
 private GraphNode ParseNamedType(NamedType type, EmbeddedFile file)
 {
     return(new GraphNode(type.DisplayName, NodeType.Complex, file.Position));
 }
Esempio n. 31
0
        private void BuildLinks(Document document)
        {
            Pages pages = document.Pages;
            Page  page  = new Page(document);

            pages.Add(page);

            PrimitiveComposer composer      = new PrimitiveComposer(page);
            BlockComposer     blockComposer = new BlockComposer(composer);

            PdfType1Font font = PdfType1Font.Load(document, PdfType1Font.FamilyEnum.Courier, true, false);

            /*
             * 2.1. Goto-URI link.
             */
            {
                blockComposer.Begin(SKRect.Create(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();

                /*
                 * NOTE: This statement instructs the PDF viewer to navigate to the given URI when the link is clicked.
                 */
                new Link(page, SKRect.Create(240, 100, 100, 50), "Link annotation",
                         new GoToURI(document, new Uri("http://www.sourceforge.net/projects/clown")))
                {
                    Border = new Border(3, BorderStyleType.Beveled)
                };
            }

            /*
             * 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);
                new FileAttachment(
                    page,
                    SKRect.Create(0, -20, 10, 10),
                    "File attachment annotation",
                    FileSpecification.Get(EmbeddedFile.Get(document, filePath),
                                          fileName
                                          )
                    )
                {
                    Name           = fileAttachmentName,
                    AttachmentName = FileAttachmentImageType.PaperClip
                };

                blockComposer.Begin(SKRect.Create(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.
                 */
                new Link(
                    page,
                    SKRect.Create(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.
                        )
                    )
                {
                    Border = new Border(1, new LineDash(new float[] { 8, 5, 2, 5 }))
                };
            }

            /*
             * 2.3. Textual link.
             */
            {
                blockComposer.Begin(SKRect.Create(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();

                composer.BeginLocalState();
                composer.SetFont(font, 10);
                composer.SetFillColor(DeviceRGBColor.Get(SKColors.Blue));
                composer.ShowText(
                    "PDF Clown Project's repository at SourceForge.net",
                    new SKPoint(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 SKPoint(240, 285),
                    XAlignmentEnum.Left,
                    YAlignmentEnum.Bottom,
                    -90,
                    new GoToURI(
                        document,
                        new Uri("http://www.pdfclown.org")
                        )
                    );
                composer.End();
            }

            composer.Flush();
        }
Esempio n. 32
0
        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();
        }