ImageGear .NET v25.2 - Updated
Developer Guide / How to Work with... / CAD / How To ... / Convert ... / CAD to PDF
In This Topic
    CAD to PDF
    In This Topic

    The following CADtoPDF sample illustrates how you can create a PDF page from a CAD page:

    C#
    Copy Code
    using System.IO;
    using ImageGear.Formats;
    using ImageGear.Formats.CAD;
    
    public static void CadToPdf(string inFile, string outFile)
    {
        ImGearCADPage page = null;
    
        // Load the file.
        using (FileStream fileStream = new FileStream(inFile, FileMode.Open, FileAccess.Read))
        {
            page = (ImGearCADPage)ImGearFileFormats.LoadPage(fileStream);
        }
    
        // Save the CAD file to a PDF file.
        using (FileStream fileStream = new FileStream(outFile, FileMode.Create, FileAccess.Write))
        {
            ImGearFileFormats.SavePage(page, fileStream, ImGearSavingFormats.PDF);
        }
    }
    
    VB.NET
    Copy Code
    Imports System.IO
    Imports ImageGear.Formats
    Imports ImageGear.Formats.CAD
    
    Public Sub CadToPdf(inPath As String, outPath As String)
        Dim page As ImGearCADPage
    
        ' Load the file.
        Using fileStream As New FileStream(inPath, FileMode.Open, FileAccess.Read)
            page = ImGearFileFormats.LoadPage(fileStream)
        End Using
    
        ' Save the CAD file as a PDF file
        Using fileStream As New FileStream(outPath, FileMode.Create, FileAccess.Write)
            ImGearFileFormats.SavePage(page, fileStream, ImGearSavingFormats.PDF)
        End Using
    End Sub
    
    The sample above uses the default saving options for PDF, but these can be changed by the user based on their needs. In order to change any of the saving options you need to set page.SavingOptions["PDFSaveOptions"] to a new CADPDFSaveOptions object that has the saving options you want.