public static void Run()
        {
            try
            {
                //ExStart:ExportDGNToPdf
                // The path to the documents directory.
                string MyDir          = RunExamples.GetDataDir_ExportingDGN();
                string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn";
                // Load an existing DGN file as CadImage.
                using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath))
                {
                    // Create an object of CadRasterizationOptions class and define/set different properties
                    Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
                    rasterizationOptions.PageWidth               = 600;
                    rasterizationOptions.PageHeight              = 300;
                    rasterizationOptions.CenterDrawing           = true;
                    rasterizationOptions.ScaleMethod             = Aspose.CAD.FileFormats.Cad.ScaleType.None;
                    rasterizationOptions.AutomaticLayoutsScaling = true;

                    // Create an object of PdfOptions class as we are converting the image to PDF format and assign CadRasterizationOptions object to it.
                    Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions();
                    pdfOptions.VectorRasterizationOptions = rasterizationOptions;

                    // Call the save method of the CadImage class object.
                    cadImage.Save(MyDir + "ExportDGNToPdf_out.pdf", pdfOptions);
                }
                //ExEnd:ExportDGNToPdf
                Console.WriteLine("\nThe DGN file exported successfully to PDF.\nFile saved at " + MyDir);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Please use valid input file." + ex.Message);
            }
        }
        public static void Run()
        {
            try
            {
                //ExStart:ExportDGNAsPartofDWG

                // Input and Output file paths
                string fileName = "BlockRefDgn.dwg";
                string outPath  = fileName + ".pdf";

                // Create an instance of PdfOptions class as we are exporting the DWG file to PDF format
                Aspose.CAD.ImageOptions.PdfOptions exportOptions = new Aspose.CAD.ImageOptions.PdfOptions();

                // Load any existing DWG file as image and convert it to CadImage type
                using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Image.Load(fileName))
                {
                    // Go through each entity inside the DWG file
                    foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity baseEntity in cadImage.Entities)
                    {
                        // Check if entity is an image definition
                        if (baseEntity.TypeName == Aspose.CAD.FileFormats.Cad.CadConsts.CadEntityTypeName.DGNUNDERLAY)
                        {
                            Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay dgnFile = (Aspose.CAD.FileFormats.Cad.CadObjects.CadDgnUnderlay)baseEntity;

                            // Get external reference to object
                            System.Console.WriteLine(dgnFile.UnderlayPath);
                        }
                    }

                    // Define settings for CadRasterizationOptions object
                    exportOptions.VectorRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions()
                    {
                        PageWidth  = 1600,
                        PageHeight = 1600,
                        //CenterDrawing = true,
                        Layouts = new string[] { "Model" },
                        AutomaticLayoutsScaling = false,
                        NoScaling       = true,
                        BackgroundColor = Color.Black,
                        DrawType        = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor
                    };

                    //Export the DWG to PDF by calling Save method
                    cadImage.Save(outPath, exportOptions);
                }
                //ExEnd:ExportDGNAsPartofDWG
            }
            catch (Exception ex)
            {
                Console.WriteLine("Please use valid input file." + ex.Message);
            }
        }
      public static void Run()
      {
          //ExStart:SearchText
          // The path to the documents directory.
          string MyDir          = RunExamples.GetDataDir_DWGDrawings();
          string sourceFilePath = MyDir + "sample.dwg";

          // Load an existing DWG file as CadImage.
          using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath))
          {
              // Search for text in the file
              foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadBaseEntity entity in cadImage.Entities)
              {
                  // Please, note: we iterate through CadText entities here, but some other entities may contain text also, e.g. CadMText and others
                  if (entity.GetType() == typeof(Aspose.CAD.FileFormats.Cad.CadObjects.CadText))
                  {
                      Aspose.CAD.FileFormats.Cad.CadObjects.CadText text = (Aspose.CAD.FileFormats.Cad.CadObjects.CadText)entity;
                      System.Console.WriteLine(text.DefaultValue);
                  }
              }

              // Search for text on specific layout get all layout names and link each layout with corresponding block with entities
              Aspose.CAD.FileFormats.Cad.CadLayoutDictionary layouts = cadImage.Layouts;
              string[] layoutNames = new string[layouts.Count];
              int      i           = 0;
              foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadLayout layout in layouts.Values)
              {
                  layoutNames[i++] = layout.LayoutName;
                  System.Console.WriteLine("Layout " + layout.LayoutName + " is found");

                  // Find block, applicable for DWG only
                  Aspose.CAD.FileFormats.Cad.CadTables.CadBlockTableObject blockTableObjectReference = null;
                  foreach (Aspose.CAD.FileFormats.Cad.CadTables.CadBlockTableObject tableObject in cadImage.BlocksTables)
                  {
                      if (string.Equals(tableObject.HardPointerToLayout, layout.ObjectHandle))
                      {
                          blockTableObjectReference = tableObject;
                          break;
                      }
                  }

                  // Collection cadBlockEntity.Entities contains information about all entities on specific layout if this collection has no elements it means layout is a copy of Model layout and contains the same entities
                  Aspose.CAD.FileFormats.Cad.CadObjects.CadBlockEntity cadBlockEntity = cadImage.BlockEntities[blockTableObjectReference.BlockName];
              }

              // Export to pdf
              Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
              rasterizationOptions.PageWidth  = 1600;
              rasterizationOptions.PageHeight = 1600;
              rasterizationOptions.AutomaticLayoutsScaling = true;
              rasterizationOptions.CenterDrawing           = true;

              // Please, note: if cadBlockEntity collection mentioned above (for dwg) for selected layout or entitiesOnLayouts collection by layout's BlockTableRecordHandle (for dxf) is empty - export result file will be empty and you should draw Model layout instead
              rasterizationOptions.Layouts = new[] { "Layout1" };

              Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions();

              pdfOptions.VectorRasterizationOptions = rasterizationOptions;
              cadImage.Save(MyDir + "SearchText_out_.pdf", pdfOptions);
          }
          //ExEnd:SearchText
      }
        private List <string> GetDocumentPages(string file, string folderName, int currentPage)
        {
            List <string> lstOutput   = new List <string>();
            string        outfileName = "page_{0}";
            string        outPath     = Config.Configuration.OutputDirectory + folderName + "/" + outfileName;

            currentPage = currentPage - 1;
            Directory.CreateDirectory(Config.Configuration.OutputDirectory + folderName);
            string imagePath = string.Format(outPath, currentPage) + ".jpeg";

            if (System.IO.File.Exists(imagePath) && currentPage > 0)
            {
                lstOutput.Add(imagePath);
                return(lstOutput);
            }

            int i = currentPage;

            var filename = System.IO.File.Exists(Config.Configuration.WorkingDirectory + folderName + "/" + file)
                                ? Config.Configuration.WorkingDirectory + folderName + "/" + file
                                : Config.Configuration.OutputDirectory + folderName + "/" + file;

            using (FilePathLock.Use(filename))
            {
                try
                {
                    Aspose.CAD.Live.Demos.UI.Models.License.SetAsposeCADLicense();


                    // Load an existing CAD document
                    Aspose.CAD.FileFormats.Cad.CadImage image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(filename);

                    // Create an instance of CadRasterizationOptions
                    Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();

                    // Set image width & height
                    rasterizationOptions.PageWidth  = 1024;
                    rasterizationOptions.PageHeight = 1024;
                    // Set the drawing to render at the center of image
                    //rasterizationOptions.CenterDrawing = true;
                    //rasterizationOptions.TypeOfEntities = Aspose.CAD.ImageOptions.TypeOfEntities.Entities3D;

                    rasterizationOptions.AutomaticLayoutsScaling = true;
                    rasterizationOptions.NoScaling       = false;
                    rasterizationOptions.ContentAsBitmap = true;

                    // Set Graphics options
                    rasterizationOptions.GraphicsOptions.SmoothingMode     = Aspose.CAD.SmoothingMode.HighQuality;
                    rasterizationOptions.GraphicsOptions.TextRenderingHint = Aspose.CAD.TextRenderingHint.AntiAliasGridFit;
                    rasterizationOptions.GraphicsOptions.InterpolationMode = Aspose.CAD.InterpolationMode.HighQualityBicubic;


                    // Get the layers in an instance of CadLayersDictionary
                    var layersList = image.Layers;
                    lstOutput.Add(layersList.Count.ToString());
                    i = 0;
                    // Iterate over the layers
                    foreach (var layerName in layersList.GetLayersNames())
                    {
                        if (i == currentPage)
                        {
                            // Add the layer name to the CadRasterizationOptions's layer list
                            rasterizationOptions.Layers[i] = layerName;

                            // Create an instance of PngOptions for the resultant image
                            Aspose.CAD.ImageOptions.JpegOptions options = new Aspose.CAD.ImageOptions.JpegOptions();

                            // Set rasterization options
                            options.VectorRasterizationOptions = rasterizationOptions;
                            image.Save(imagePath, options);
                            lstOutput.Add(imagePath);
                            image.Dispose();
                            break;
                        }
                        i++;
                    }
                    if (!image.Disposed)
                    {
                        image.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                return(lstOutput);
            }
        }