Printed Circuit Boards (PCBs), as integral components of electronic products, play a crucial role in modern industrial production. However, due to the precision and complexity of PCBs, existing PCB defect detection methods exhibit some issues such as low detection accuracy and limited usability. In order to address these problems, a PCB defect detection method based on D-DenseNet (PCBDD-DDNet) has been proposed. This method capitalizes on the advantages of two deep learning networks, CDBN (Convolutional Deep Belief Networks) and DenseNet (Densely Connected Convolutional Networks), to construct the D-DenseNet (Combination of CDBN and DenseNet) network. Within this network, CDBN focuses on extracting low-level features, while DenseNet is responsible for high-level feature extraction. The outputs from both networks are integrated using a weighted averaging approach. Additionally, the D-DenseNet employs a multi-scale module to extract features from different levels. This is achieved by incorporating filters of sizes 3 × 3, 5 × 5, and 7 × 7 along the three paths of the CDBN network, multi-scale feature extraction network, and DenseNet network, effectively capturing information at various scales. To prevent overfitting and enhance network performance, the Adafactor optimization function and L2 regularization are introduced. Finally, online hard example mining mechanism (OHEM) is incorporated to improve the network’s handling of challenging samples and enhance the accuracy of the PCB defect detection network. The effectiveness of this PCBDD-DDNet method is demonstrated through experiments conducted on publicly available PCB datasets. And the method achieves a mAP (mean Average Precision) of 93.24%, with an accuracy higher than other classical networks. The results affirm the method’s efficacy in PCB defect detection.