Method and device for converting DWG drawing into PDF file and conversion storage access system

By leveraging AutoCAD's secondary development tools and end-to-end processing system, DWG drawings can be converted into PDF files, resolving issues such as browsers' inability to read local files and the clarity of preview images, thus enabling efficient drawing sharing and collaboration.

CN121809404APending Publication Date: 2026-04-07WUHAN SANJIANG SPACE NETWORK COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-08
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Browsers cannot directly read local DWG files, and existing file processing solutions are inefficient and cannot guarantee the clarity of preview images, making it difficult to share and collaborate on drawings in engineering design.

Method used

By using AutoCAD's secondary development tools, a rectangle can be selected and DWG drawings can be converted into PDF files according to printing parameters. By combining CAD plugins, browsers, and servers, a full-chain processing system can be built to realize drawing format conversion, cloud storage management, and multi-terminal collaborative access.

Benefits of technology

Simplify the operation process, improve the efficiency of drawing processing and the convenience of collaboration, ensure the clarity of drawings, avoid design errors, and improve the accuracy of retrieval and version management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121809404A_ABST
    Figure CN121809404A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for converting a DWG drawing into a PDF file and a conversion storage access system, which are realized based on a secondary development tool of AutoCAD, and the method comprises the following steps: selecting a rectangular frame from the DWG drawing, the rectangular frame being determined by two diagonal points; pDF printing is conducted according to the printing parameters, a PDF file obtained through printing is stored to a designated path, the printing parameters comprise the printing direction, the printing style, a printer, the paper size and a rectangular frame, the printing style is PCCAD. CTB, the printer is DWG TO PDF.PC3, and the paper size is determined according to the two diagonal points. The invention provides a method and device for converting a DWG drawing into a PDF file and a conversion storage access system, and aims to solve the problems that browser file access is limited when a CAD preview is obtained through a browser, existing file processing schemes are insufficient, and the definition of the preview is difficult to guarantee.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer-aided design (CAD) and document processing technology, and in particular to a method, apparatus and conversion storage access system for converting DWG drawings to PDF files. Background Technology

[0002] In engineering design and collaboration, CAD drawings are an important form of design deliverables. Currently, obtaining CAD previews through a browser presents the following technical challenges: Browser File Access Restrictions: Due to the browser's same-origin policy and security sandbox mechanism, it cannot directly read DWG files in the local file system. The same-origin policy strictly restricts web pages to accessing resources from the same origin (same protocol, domain name, and port), preventing cross-origin access to local files, thereby ensuring the security of users' local files and preventing malicious web pages from illegally reading users' private files; the security sandbox technology isolates the web page's operating environment from the local system, ensuring that even if the browser is attacked, local data will not be threatened. In addition, DWG files, as AutoCAD-specific binary format files, have a complex structure and professional characteristics, further increasing the difficulty for browsers to directly parse and process them.

[0003] Existing file processing solutions are inadequate: Traditional DWG file processing methods, such as manually converting the format and then transmitting via email or storage media, are inefficient and prone to problems like version inconsistencies and difficulties in collaboration. Although some software supports online conversion, it lacks a complete closed-loop processing from the CAD end to the browser end. When retrieving a specified PDF converted from CAD from a server via a browser, existing solutions often require users to perform cumbersome operations, such as manually finding the file path, downloading and uploading files multiple times, which is insufficient to meet the needs of efficient sharing, accurate merging, and rapid collaboration of drawings in engineering design.

[0004] Preview image clarity is difficult to guarantee: In the drawing preview stage, existing technologies mostly use bitmap formats to generate preview images, which are prone to distortion such as jagged edges and blurring when zoomed in or out, failing to meet the stringent requirements of engineering design for drawing clarity. Low-quality preview images not only affect work efficiency but may also lead to design errors due to visual biases. Summary of the Invention

[0005] This invention provides a method, apparatus, and conversion storage access system for converting DWG drawings to PDF files, in order to solve the problems of browser file access restrictions, insufficient existing file processing solutions, and difficulty in guaranteeing the clarity of preview images when obtaining CAD preview images through a browser.

[0006] In a first aspect, the present invention provides a method for converting DWG drawings to PDF files, implemented based on a secondary development tool for AutoCAD, comprising: Select a rectangle from the DWG drawing, the rectangle being defined by two diagonal points; The PDF is printed according to the printing parameters, and the printed PDF file is saved to the specified path. The printing parameters include printing orientation, printing style, printer, paper size and the rectangle. The printing style is PCCAD.CTB, the printer is DWG TO PDF.PC3, and the paper size is determined based on the two diagonal points.

[0007] Optionally, the paper size is determined based on the two diagonal points, including: The side lengths of the rectangle in the x-axis and y-axis directions are determined based on the two diagonal points, and the paper size is determined based on the side lengths of the rectangle in the x-axis and y-axis directions.

[0008] The above solution is based on secondary development tools to further develop the CAD platform. It designs the conversion process from DWG drawings to PDF files according to user needs, ensuring the clarity of the preview image from the source, simplifying the operation process, reducing the complexity of operation, and improving operation efficiency and experience.

[0009] Secondly, this invention provides a device for converting DWG drawings to PDF files, implemented using a secondary development tool for AutoCAD, comprising a rectangular selection module and a file conversion module, wherein: The rectangular selection module is used to select a rectangular frame from a DWG drawing, and the rectangular frame is defined by two diagonal points. The file conversion module is used to print PDF according to the printing parameters and save the printed PDF file to a specified path. The printing parameters include printing orientation, printing style, printer, paper size and the rectangle. The printing style is PCCAD.CTB, the printer is DWG TO PDF.PC3, and the paper size is determined based on the two diagonal points.

[0010] Thirdly, the present invention provides a conversion storage access system, including a CAD plugin, a browser, and a server. The CAD plugin includes the aforementioned device and a file upload module. The browser includes a user interaction module, a file acquisition module, and a file merging module. The server includes an API interface module, an ID generation module, a file storage module, and a database, wherein: The file upload module is used to send a PDF file located at a specified path to the API interface module and receive the ID returned by the API interface module; The user interaction module is used to input the ID of the PDF file to be retrieved; The file acquisition module is used to generate a file acquisition request based on the ID of the PDF file to be acquired, send the file acquisition request to the API interface module, and receive the PDF file sent by the API interface module. The file merging module is used to merge the PDF files received by the file acquisition module into a target file and store the target file; The API interface module is used to receive the PDF file sent by the file upload module, return the ID sent by the ID generation module to the file upload module, receive the file acquisition request, and send the PDF file to be acquired to the file acquisition module according to the file acquisition request; The ID generation module is used to generate an ID for each PDF file received by the API interface module, and send the generated ID to the API interface module and the file storage module. The file storage module is used to store the PDF file received by the API interface module to a specified address, and save the specified address and the ID sent by the ID generation module to the database; The database is used to store the specified address and the ID sent by the ID generation module.

[0011] Optionally, the file upload module is also used to add the received ID to the system clipboard.

[0012] Optionally, sending the PDF file to be acquired to the file acquisition module according to the file acquisition request includes: Extract the ID of the PDF file to be retrieved from the file retrieval request; The validity of the ID of the PDF file to be acquired is verified. If the verification is successful, the specified address is retrieved from the database, the PDF file to be retrieved is found from the specified address according to the ID of the PDF file to be retrieved, and the PDF file to be retrieved is sent to the file retrieval module; If the verification fails, an ID error message is returned to the file acquisition module.

[0013] Optionally, the validity verification of the ID of the PDF file to be obtained includes: Determine whether the ID of the PDF file to be obtained exists in the database; If it exists, the verification passes; If it does not exist, the verification fails.

[0014] Optionally, the data interaction between the API interface module and the file upload module and the file acquisition module is implemented based on the WebSocket protocol.

[0015] Optionally, the server is built using the JAVA language.

[0016] Optionally, the merging of the PDF file received by the file acquisition module into the target file is achieved using iText7.

[0017] The above solution constructs a three-in-one processing system integrating CAD plugins, browsers, and servers, connecting the entire process of drawing format conversion, cloud storage management, multi-terminal collaborative access, and intelligent merging. This significantly reduces manual intervention, effectively shortens project delivery cycles, and improves the efficiency and convenience of engineering drawing processing and collaboration. By specifying commands, DWG drawings can be quickly converted into vector-format PDF files, ensuring the clarity of the drawings from the source and meeting the stringent accuracy requirements of engineering design. This avoids design errors caused by image distortion and solves the problem of browsers not being able to directly read local DWG files. It eliminates the need to repeatedly upload the same drawings, reducing repetitive work when multiple projects reuse drawing resources, further improving overall work efficiency. A file index system based on a unique ID generated by the server replaces the traditional naming path identification method, enabling precise data interaction between the browser and server, significantly improving the efficiency of engineering drawing retrieval and the accuracy of version management. The browser integrates a PDF processing engine, supporting precise merging functionality, and can flexibly handle complex business scenarios such as drawing splicing and version comparison in engineering design. Attached Figure Description

[0018] Figure 1 A flowchart illustrating a method for converting DWG drawings to PDF files, provided by an embodiment of the present invention; Figure 2 This is a schematic diagram of a device for converting DWG drawings to PDF files according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the architecture of a conversion storage access system provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the user interface of the user interaction module provided in an embodiment of the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0020] Figure 1 This invention illustrates a flowchart of a method for converting DWG drawings to PDF files, implemented using AutoCAD secondary development tools, and includes: S101, Select a rectangle from the DWG drawing. The rectangle is defined by two diagonal points.

[0021] It should be noted that in AutoCAD software, the rectangular frame in DWG drawings is selected by using the mouse.

[0022] S102, Print PDF according to printing parameters and save the printed PDF file to the specified path.

[0023] Specifically, the printing parameters include printing orientation, printing style, printer, paper size, and rectangle. The printing style is PCCAD.CTB, the printer is DWG TO PDF.PC3, and the paper size is determined based on two diagonal points.

[0024] In one example, the paper size is determined based on two diagonal points, including: Determine the side lengths of the rectangle along the x and y axes based on the two diagonal points, and then determine the paper size based on the side lengths of the rectangle along the x and y axes.

[0025] In one possible implementation, the pseudocode for the print PDF function is as follows: Function ExPdfExpdf(): Get the first point p1 and the diagonal point p2 specified by the user. Adjust the point coordinates to ensure that p1 is at the bottom left and p2 is at the top right. / / Determine paper size Get the y-axis side length l and x-axis side length w of rectangles p1 and p2. If l > w: Paper size = "ISO_A4_(210.00_x_297.00_MM)" Otherwise, if l < w: Paper size = "ISO_A4_(297.00_x_210.00_MM)" Otherwise: Paper size = "ISO_A4_(297.00_x_210.00_MM)" / / Generate PDF filename (based on the current DWG file path and name) PDF filename=current drawing path+replace the current drawing file name with ".PDF" as the file extension. If the PDF file already exists, delete it. / / Set printing parameters Set the print orientation to 0 degrees (i.e., rotate 0 degrees). Check if the "PCCAD.CTB" print style exists. The style PCCAD.CTB was not found. The message box displayed "Unable to find print style PCCAD.CTB" indicates that the print style could not be found. return Set the current print style to "PCCAD.CTB" If the setup fails: The message box displayed "Failed to set print style!" return Check if the "DWG TO PDF.PC3" printer exists. If the printer DWG TO PDF.PC3 is not found: A message box appears saying "Unable to obtain printer". return Set the printer to "DWG TO PDF.PC3" Set the current paper size to the previously determined paper size. Set to use standard ratio Set the scale to "Fit to Drawing". Set print center Set the print window area to the rectangular area from p1 to p2. Set the print type to "Window". Create and configure the print progress dialog box Display printing progress / / Execute the printing process Start printing task Configure print page information Verify print parameters Get the current document name Start printing the document (output to PDF file). Start processing single pages Set page progress range Generate printable graphics Print the completed page Update progress is 100%. Complete document printing End print job It should be noted that DWG drawings are converted into PDF files in vector graphics format. Vector graphics, with their ability to scale infinitely without loss of quality, can provide high-quality previews of engineering drawings, ensuring the clarity of the preview images from the source.

[0026] AutoCAD's secondary development tools include ObjectARX and the .NET API. ObjectARX is a C++ development tool; the .NET API is based on the .NET Framework and supports languages ​​such as C# and VB.NET. ObjectARX and the .NET API differ in their settings for the same functionality. For example, ObjectARX's settings for printers and print styles are as follows: pPSV->setPlotCfgName(pPlotSettings,_T("DWG TO PDF.PC3")); pPSV->setCurrentStyleSheet(pPlotSettings,_T("PCCAD.CTB")); The .NET API provides the following settings for printers and print styles: Doc.ActiveLayout.ConfigName = "DWG TO PDF.PC3"; Doc.ActiveLayout.StyleSheet = "PCCAD.CTB".

[0027] The above solution is based on secondary development tools to further develop the CAD platform. It designs the conversion process from DWG drawings to PDF files according to user needs, ensuring the clarity of the preview image from the source, simplifying the operation process, reducing the complexity of operation, and improving operation efficiency and experience.

[0028] Based on the same inventive concept. Figure 2 This invention illustrates the structure of a device for converting DWG drawings to PDF files, implemented using a secondary development tool for AutoCAD. The device includes a rectangular selection module and a file conversion module. The rectangular selection module is used to select a rectangle from a DWG drawing. The rectangle is defined by two diagonal points. The file conversion module is used to print PDFs according to printing parameters and save the printed PDF files to a specified path. Printing parameters include printing orientation, printing style, printer, paper size, and rectangle. The printing style is PCCAD.CTB, the printer is DWG TO PDF.PC3, and the paper size is determined based on two diagonal points.

[0029] Based on the same inventive concept. Figure 3This invention illustrates the architecture of a conversion storage access system provided by an embodiment of the present invention, including a CAD plugin, a browser, and a server. The CAD plugin includes the aforementioned device and a file upload module. The browser includes a user interaction module, a file acquisition module, and a file merging module. The server includes an API interface module, an ID generation module, a file storage module, and a database, wherein: The file upload module is used to send PDF files located at a specified path to the API interface module and receive the ID returned by the API interface module. The user interaction module is used to input the ID of the PDF file to be retrieved; The file acquisition module is used to generate a file acquisition request based on the ID of the PDF file to be acquired, send the file acquisition request to the API interface module, and receive the PDF file sent by the API interface module. The file merging module is used to merge the PDF files received by the file acquisition module into the target file and store the target file; The API interface module is used to receive PDF files sent by the file upload module, return the ID sent by the ID generation module to the file upload module, receive file retrieval requests, and send the PDF file to be retrieved to the file retrieval module according to the file retrieval requests. The ID generation module is used to generate an ID for each PDF file received by the API interface module, and send the generated ID to the API interface module and the file storage module. The file storage module is used to store the PDF files received by the API interface module to a specified address, and save the specified address and the ID sent by the ID generation module to the database; The database is used to store the IDs sent by the ID generation module at the specified address.

[0030] The CAD plugin is developed based on AutoCAD's secondary development tools and compiled into an ARX format plugin. It can be used by selecting "Manage" -> "Load Application" -> "Load the generated ARX file" from the CAD interface menu. The CAD plugin is embedded in CAD; it can be invoked by entering a specified command in the CAD command input box. In this embodiment, the specified command is "um".

[0031] In one example, the file upload module is also used to add the received ID to the system clipboard.

[0032] This operation is equivalent to the user selecting the ID text and then right-clicking to copy or using the shortcut Ctrl+C to copy, saving the user the trouble of manually selecting the ID and copying it, reducing the cumbersome operation process and making it more in line with the user's operating habits.

[0033] In one example, the ID consists of the initials of the company name and a randomly generated UUID code.

[0034] In one example, sending the PDF file to be retrieved to the file retrieval module based on the file retrieval request includes: Extract the ID of the PDF file to be retrieved from the file retrieval request; Validate the validity of the ID of the PDF file to be retrieved; If the verification passes, retrieve the specified address from the database, find the PDF file to be retrieved from the specified address based on the ID of the PDF file to be retrieved, and send the PDF file to be retrieved to the file retrieval module; If the verification fails, return an ID error message to the file retrieval module.

[0035] Furthermore, validating the ID of the PDF file to be retrieved includes: Determine if the ID of the PDF file to be retrieved exists in the database; If it exists, the verification passes; If it does not exist, the verification fails.

[0036] In one example, the data interaction between the API interface module and the file upload and file retrieval modules is implemented based on the WebSocket protocol.

[0037] In one example, the server is built using the Java language.

[0038] Furthermore, the PDF files received by the file acquisition module are merged into the target file using iText 7. iText 7 is an open-source Java library that supports the development and conversion of PDF documents.

[0039] Figure 4 The user interface of the interaction module is shown, including an ID input box and a "Confirm" button.

[0040] It should be noted that merging will combine PDF files into a single page of the target file.

[0041] In one example, the target file is a target process PDF file.

[0042] The above solution constructs a three-in-one processing system integrating CAD plugins, browsers, and servers, connecting the entire process of drawing format conversion, cloud storage management, multi-terminal collaborative access, and intelligent merging. This significantly reduces manual intervention, effectively shortens project delivery cycles, and improves the efficiency and convenience of engineering drawing processing and collaboration. By specifying commands, DWG drawings can be quickly converted into vector-format PDF files, ensuring the clarity of the drawings from the source and meeting the stringent accuracy requirements of engineering design. This avoids design errors caused by image distortion and solves the problem of browsers not being able to directly read local DWG files. It eliminates the need to repeatedly upload the same drawings, reducing repetitive work when multiple projects reuse drawing resources, further improving overall work efficiency. A file index system based on a unique ID generated by the server replaces the traditional naming path identification method, enabling precise data interaction between the browser and server, significantly improving the efficiency of engineering drawing retrieval and the accuracy of version management. The browser integrates a PDF processing engine, supporting precise merging functionality, and can flexibly handle complex business scenarios such as drawing splicing and version comparison in engineering design.

[0043] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0044] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0045] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1The function specified in one or more boxes.

[0046] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0047] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0048] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for converting DWG drawings to PDF files, characterized in that, The implementation is based on AutoCAD secondary development tools, including: Select a rectangle from the DWG drawing, the rectangle being defined by two diagonal points; The PDF is printed according to the printing parameters, and the printed PDF file is saved to the specified path. The printing parameters include printing orientation, printing style, printer, paper size and the rectangle. The printing style is PCCAD.CTB, the printer is DWG TO PDF.PC3, and the paper size is determined based on the two diagonal points.

2. The method according to claim 1, characterized in that, The paper size is determined based on the two diagonal points, including: The side lengths of the rectangle in the x-axis and y-axis directions are determined based on the two diagonal points, and the paper size is determined based on the side lengths of the rectangle in the x-axis and y-axis directions.

3. A device for converting DWG drawings to PDF files, characterized in that, This is an implementation based on a secondary development tool for AutoCAD, including a rectangular selection module and a file conversion module, wherein: The rectangular selection module is used to select a rectangular frame from a DWG drawing, and the rectangular frame is defined by two diagonal points. The file conversion module is used to print PDF according to the printing parameters and save the printed PDF file to a specified path. The printing parameters include printing orientation, printing style, printer, paper size and the rectangle. The printing style is PCCAD.CTB, the printer is DWG TO PDF.PC3, and the paper size is determined based on the two diagonal points.

4. A conversion storage access system, characterized in that, The system includes a CAD plugin, a browser, and a server. The CAD plugin includes the device described in claim 3 and a file upload module. The browser includes a user interaction module, a file acquisition module, and a file merging module. The server includes an API interface module, an ID generation module, a file storage module, and a database. The file upload module is used to send a PDF file located at a specified path to the API interface module and receive the ID returned by the API interface module; The user interaction module is used to input the ID of the PDF file to be retrieved; The file acquisition module is used to generate a file acquisition request based on the ID of the PDF file to be acquired, send the file acquisition request to the API interface module, and receive the PDF file sent by the API interface module. The file merging module is used to merge the PDF files received by the file acquisition module into a target file and store the target file; The API interface module is used to receive the PDF file sent by the file upload module, return the ID sent by the ID generation module to the file upload module, receive the file acquisition request, and send the PDF file to be acquired to the file acquisition module according to the file acquisition request; The ID generation module is used to generate an ID for each PDF file received by the API interface module, and send the generated ID to the API interface module and the file storage module. The file storage module is used to store the PDF file received by the API interface module to a specified address, and save the specified address and the ID sent by the ID generation module to the database; The database is used to store the specified address and the ID sent by the ID generation module.

5. The system according to claim 4, characterized in that, The file upload module is also used to add the received ID to the system clipboard.

6. The system according to claim 4, characterized in that, Sending the PDF file to be acquired to the file acquisition module according to the file acquisition request includes: Extract the ID of the PDF file to be retrieved from the file retrieval request; The validity of the ID of the PDF file to be acquired is verified. If the verification is successful, the specified address is retrieved from the database, the PDF file to be retrieved is found from the specified address according to the ID of the PDF file to be retrieved, and the PDF file to be retrieved is sent to the file retrieval module; If the verification fails, an ID error message is returned to the file acquisition module.

7. The system according to claim 6, characterized in that, The validity verification of the ID of the PDF file to be obtained includes: Determine whether the ID of the PDF file to be obtained exists in the database; If it exists, the verification passes; If it does not exist, the verification fails.

8. The system according to claim 4, characterized in that, The data interaction between the API interface module, the file upload module, and the file acquisition module is implemented based on the WebSocket protocol.

9. The system according to claim 4, characterized in that, The server is built using the JAVA language.

10. The system according to claim 9, characterized in that, The process of merging the PDF file received by the file acquisition module into the target file is implemented using iText 7.