public static void Run() { //ExStart:DWGToCompliancePDF // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string sourceFilePath = MyDir + "Bottom_plate.dwg"; Aspose.CAD.Image cadImage = Aspose.CAD.Image.Load(sourceFilePath); // Create an instance of CadRasterizationOptions and set its various properties Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White; rasterizationOptions.PageWidth = 1600; rasterizationOptions.PageHeight = 1600; // Create an instance of PdfOptions PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions { VectorRasterizationOptions = rasterizationOptions }; pdfOptions.CorePdfOptions = new PdfDocumentOptions(); pdfOptions.CorePdfOptions.Compliance = PdfCompliance.PdfA1a; cadImage.Save(MyDir + "PDFA1_A.pdf", pdfOptions); pdfOptions.CorePdfOptions.Compliance = PdfCompliance.PdfA1b; cadImage.Save(MyDir + "PDFA1_B.pdf", pdfOptions); //ExEnd:DWGToCompliancePDF Console.WriteLine("\nThe DWG file exported successfully to PDF.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:SupportOfBlockClipping // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DXFDrawings(); string inputFile = MyDir + "SLS-CW-CD-CE001-R01_blockClip.dxf"; string outputFile = MyDir + "SLS-CW-CD-CE001-R01_blockClip.pdf"; using (CadImage cadImage = (CadImage)Image.Load(inputFile)) { var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions { BackgroundColor = Aspose.CAD.Color.White, DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor, PageWidth = 1200, PageHeight = 1600, BorderX = 30, BorderY = 5, Layouts = new string[] { "Model" } }; PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions { VectorRasterizationOptions = rasterizationOptions }; cadImage.Save(outputFile, pdfOptions); //ExEnd:SupportOfBlockClipping } }
///<Summary> /// ConvertCadToPdf method to convert cad to pdf ///</Summary> public Response ConvertCadToPdf(string fileName, string folderName, string outputType) { return(ProcessTask(fileName, folderName, ".pdf", false, false, delegate(string inFilePath, string outPath, string zipOutFolder) { using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(inFilePath)) { Aspose.CAD.ImageOptions.PdfOptions pdfSaveOptions = new Aspose.CAD.ImageOptions.PdfOptions(); if (outputType == "pdfa_1b") { pdfSaveOptions.CorePdfOptions.Compliance = CAD.ImageOptions.PdfCompliance.PdfA1b; } else if (outputType == "pdfa_1a") { pdfSaveOptions.CorePdfOptions.Compliance = CAD.ImageOptions.PdfCompliance.PdfA1a; } else if (outputType == "pdf_15") { pdfSaveOptions.CorePdfOptions.Compliance = CAD.ImageOptions.PdfCompliance.Pdf15; } using (Stream stream = new FileStream(outPath, FileMode.CreateNew)) { image.Save(stream, pdfSaveOptions); } } })); }
public static void Run() { //ExStart:1 // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string sourceFilePath = MyDir + "visualization_-_conference_room.dwg"; using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) { CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.Layouts = new string[] { "Model" }; rasterizationOptions.NoScaling = true; // note: preserving some empty borders around part of image is the responsibility of customer // top left point of region to draw Point topLeft = new Point(500, 1000); double width = 3108; double height = 2489; CadVportTableObject newView = new CadVportTableObject(); newView.Name = new CadStringParameter(); newView.Name.Init("*Active"); newView.CenterPoint.X = topLeft.X + width / 2f; newView.CenterPoint.Y = topLeft.Y - height / 2f; newView.ViewHeight.Value = height; newView.ViewAspectRatio.Value = width / height; for (int i = 0; i < cadImage.ViewPorts.Count; i++) { CadVportTableObject currentView = (CadVportTableObject)(cadImage.ViewPorts[i]); if (cadImage.ViewPorts.Count == 1 || string.Equals(currentView.Name.Value.ToLowerInvariant(), "*active")) { cadImage.ViewPorts[i] = newView; break; } } // Create an instance of PdfOptions Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); // Set the VectorRasterizationOptions property pdfOptions.VectorRasterizationOptions = rasterizationOptions; MyDir = MyDir + "ConvertDWGToPDFBySupplyingCoordinates_out.pdf"; //Export the DWG to PDF cadImage.Save(MyDir, pdfOptions); } //ExEnd:1 Console.WriteLine("\nThe DWG file exported successfully to PDF.\nFile saved at " + MyDir); }