### Join Paths with Platform Separators (Python) Source: https://developers.scan2cad.com/python/index The `s2c.join` class simplifies path construction by using the appropriate path separator for the current operating system. It takes a base path and any number of additional path components as arguments. ```python import s2c # Join paths using platform-specific separators full_path = s2c.join('/home/user', 'data', 'images', 'file.png') # On Windows, this might be 'C:\Users\user\data\images\file.png' # On Linux, this might be '/home/user/data/images/file.png' ``` -------------------------------- ### Convert PDFs to DXF Files (Python) Source: https://developers.scan2cad.com/python/index The `s2c.PDFsInDirToDxfs` class is designed to extract vector data from all PDF files located in a specified input directory and save them as DXF files in an output directory. This is a core utility for batch conversion tasks. ```python import s2c # Convert all PDFs in 'input_pdfs' to DXF in 'output_dxf' s2c.PDFsInDirToDxfs('/path/to/input_pdfs', '/path/to/output_dxf') ``` -------------------------------- ### List Files in Directory (Python) Source: https://developers.scan2cad.com/python/index The `s2c.list` class allows you to list files within a specified directory. It can filter files by a given extension, which can be a single string or a list of strings. This is useful for processing specific file types within a folder. ```python import s2c # List all files in a directory files = s2c.list('/path/to/directory') # List only PDF files pdf_files = s2c.list('/path/to/directory', extension='.pdf') # List multiple file types image_files = s2c.list('/path/to/directory', extension=['.png', '.jpg', '.tiff']) ``` -------------------------------- ### Vectorize Images in a Directory using Scan2CAD Source: https://developers.scan2cad.com/python/index This code snippet shows how to vectorize all PNG images found in a given directory using the Scan2CAD Python API. It opens each image, applies vectorization using a default preset, and saves the resulting vector image. This function requires the 's2c' library. ```python import scan2cad as s2c in_dir = "path/to/input_directory" preset = s2c.Preset() # Uses default vectorization settings imgs = s2c.list(in_dir, "png") # Lists all PNG files in the directory for i in imgs: r = i.open() # Opens the raster image v = r.vectorize(preset) # Vectorizes the image v.save(r.path) # Saves the vectorized image to the original path ``` -------------------------------- ### Extract Raster Images from PDF using Scan2CAD Source: https://developers.scan2cad.com/python/index This snippet demonstrates how to extract all raster images from PDF files within a specified directory using the Scan2CAD Python API. It iterates through PDF files, opens them, and saves any extracted raster images to the same directory. Dependencies include the 's2c' library. ```python import scan2cad as s2c in_dir = "path/to/input_directory" pdfs = s2c.list(in_dir, "pdf") for p in pdfs: pp = p.open() # Opens the PDF file # Saves extracted raster images to the input directory pp.save(s2c.FileType.RASTER, s2c.join(in_dir, p.get_name())) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.