Method for converting DocuWorks document into PDF document
By using DocuWorks software to operate the SDK and registry parameter modification technology, the problem of non-standard page size distortion when converting multi-page DocuWorks documents to PDF documents is solved, and the original size of the document is automatically converted and efficient conversion efficiency is achieved.
Patent Information
- Application Number
- CN202510362202.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-26
- Publication Date
- 2025-04-25
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing technology cannot effectively solve the problem of size distortion of non-standard size pages when converting multi-page DocuWorks documents to PDF documents, resulting in the converted documents being unable to be used normally.
By reading the database, find the list of drawings that need to be converted, use the DocuWorks software to operate the SDK to obtain the number of document pages and page size, and determine whether the size of each page is the standard size. If there are non-standard size pages, split the document, modify the registry parameters, print a single page and merge it into a complete PDF document.
The automatic conversion of DocuWorks documents of non-standard size pages to PDF documents is realized, which improves document conversion efficiency and solves the problem of distortion of multiple page conversion dimensions in the prior art.
Abstract
Description
Technical Field
[0001] The invention relates to a document conversion method, in particular to a method for converting a DocuWorks document into a PDF document, and belongs to the field of software technology. Background Art
[0002] DocuWorks is a document management software developed by Fuji Xerox. Its documents usually have the extension .xdw. DocuWorks documents are layout documents similar to PDF documents. Since DocuWorks documents are not widely used, electronic drawings for external use need to be converted into PDF format for delivery.
[0003] DocuWorks software has a built-in function to convert DocuWorks documents into PDF documents, but for multi-page DocuWorks documents, it can only recognize A3 or A4 size, and other non-standard size pages can only be output as A4. The converted document size is distorted and cannot be used normally. If processed manually, a single document will take a lot of time. Faced with the company's huge daily drawing conversion needs, manual conversion cannot meet the needs. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method for converting a DocuWorks document into a PDF document, so as to solve the problem of non-standard size distortion when converting a multi-page DocuWorks document into a PDF document.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: A method for converting a DocuWorks document into a PDF document comprises the following steps: S1. Find the list of drawings that need to be converted by reading the database, and wait for conversion in sequence in a queue; S2. Obtain the number of pages of the DocuWorks document through the interface provided in the DocuWorks software operation SDK, loop through all the pages of the DocuWorks document and obtain the page sizes of all the DocuWorks documents, and determine whether the page size of each DocuWorks document page is a standard size; S3. If the DocuWorks document page sizes of all pages in the DocuWorks document are standard sizes, set the PDF virtual printer provided by the DocuWorks software as the default printer to print the entire DocuWorks document; S4. If there is a non-standard DocuWorks document page size in the DocuWorks document, single-page printing is performed to generate a single-page PDF, and then the single-page PDFs are merged into a complete PDF document.
[0006] Furthermore, the step S2 is specifically as follows: 2.1. Obtain the number of pages of the DocuWorks document through the interface provided in the DocuWorks software operation SDK; 2.2. Loop through all DocuWorks document pages and obtain the DocuWorks document page size; 2.3. Compare the page size of each DocuWorks document page with the page size of the A3 file and the page size of the A4 file; 2.4. If the page size of a DocuWorks document is the same as that of an A3 file or an A4 file, the page size of the DocuWorks document is the standard size. 2.5. If the page size of a DocuWorks document is different from the page size of an A3 file and the page size of an A4 file, the page size of the DocuWorks document is a non-standard size.
[0007] Furthermore, the step S4 is specifically as follows: 4.1. Use SDK: Xdwapiwn interface to split DocuWorks document into DocuWorks single-page files; 4.2. Get the page size of a DocuWorks single-page document; 4.3. Copy the registry key template file; 4.4. Replace the page parameters in the registry key template file to modify the size and orientation of the DocuWorks single-page document; 4.5. Call batch processing to import the registry into the system; 4.6. Set the PDF virtual printer that comes with the DocuWorks software as the default printer, print the current DocuWorks single-page file to obtain a PDF single-page file and name the PDF single-page file with the page number; 4.7. Store the PDF single-page files into the PDF document array in the order of naming; 4.8. Use the control to synthesize the printed PDF single-page files into a complete PDF document according to the PDF document array.
[0008] Furthermore, the step 4.1 is specifically as follows: 4.1.1、Call the DocuWorks software SDK: Xdwapiwn interface in the C# program; 4.1.2、Define the DocuWorks document handle variable handle, define the DocuWorks document opening mode variable mode, set the DocuWorks document opening mode to update, and define the DocuWorks document information variable info; 4.1.3. Open the DocuWorks document through the XDW_OpenDocumentHandle interface and assign a value to the handle variable handle; 4.1.4. Assign the DocuWorks document information to the information variable info through the XDW_GetDocumentInformation interface; 4.1.5. Get the number of pages of a DocuWorks document from the DocuWorks document properties; 4.1.6. Loop from the first page to the last page, and save each DocuWorks document page as a DocuWorks single-page file named with the page number through the XDW_GetPage interface.
[0009] Furthermore, the step 4.4 is specifically as follows: 4.4.1. Convert the page height key value into the page height in millimeters and take the integer part to obtain the first page height value n22. The remaining decimal part of the page height is rounded off and magnified by 10 times to obtain the second page height value n21. 4.4.2. Convert the page width key value into the page width in millimeters and take the integer part to obtain the first page width value n12. Round off the remaining decimal part of the page width and magnify it by 10 times to obtain the second page width value n11. 4.4.3. Convert the first page height value n22, the second page height value n21, the first page width value n12, and the second page width value n11 into hexadecimal to obtain a hexadecimal first page height value n4, a hexadecimal second page height value n3, a hexadecimal first page width value n2, and a hexadecimal second page width value n1; 4.4.4、Define the first string replace1=n1、n2、n3、n4, and define the second string replace2=n3、n4、n1、n2; 4.4.5. If the page height key value is less than or equal to the page width key value, fill the first string replace1 into the registry replacement parameter PARTa; 4.4.6. If the page height key value is greater than the page width key value, the second string replace2 is filled into the registry replacement parameter PARTa.
[0010] Furthermore, the step 4.5 is specifically to create a batch document input.bat in the system, the content of the batch document input.bat is: regedit / s C:\regedit\new.reg, where new.reg is the reg file of the replaced parameter PARTa, and run Process.Start(@"C:\regedit\input.bat") in the C# program.
[0011] Furthermore, the step 4.8 is specifically to use the MergeFiles interface of the spire control to merge all the PDF single-page documents in the PDF document array into a complete PDF document in the order of naming.
[0012] Compared with the prior art, the present invention has the following advantages and effects: the present invention provides a method for converting a DocuWorks document into a PDF document, by splitting the DocuWorks document and determining whether it is a non-standard size, for non-standard size pages, calling an interface to modify registry parameters to achieve conversion of non-standard size pages, and then printing a single page, thereby achieving automatic conversion of DocuWorks documents with non-standard size pages to the original size of PDF documents, improving document conversion efficiency, and solving the problem of size distortion in multi-page conversion in the prior art. DETAILED DESCRIPTION
[0013] In order to elaborate on the technical scheme adopted by the present invention to achieve the predetermined technical purpose, the technical scheme in the embodiments of the present invention is clearly and completely described below. Obviously, the described embodiments are only partial embodiments of the present invention, rather than all embodiments, and the technical means or technical features in the embodiments of the present invention can be replaced without paying creative labor. The present invention will be described in detail below in conjunction with the embodiments.
[0014] A method for converting a DocuWorks document into a PDF document of the present invention comprises the following steps: S1. Find the list of drawings that need to be converted by reading the database, and wait for conversion in sequence through a queue.
[0015] S2. Obtain the number of pages of the DocuWorks document through the interface provided in the DocuWorks software operation SDK, loop through all the pages of the DocuWorks document and obtain the page sizes of all the DocuWorks documents, and determine whether the page size of each DocuWorks document page is a standard size.
[0016] 2.1. Obtain the number of pages of the DocuWorks document through the interface provided in the DocuWorks software operation SDK.
[0017] 2.2. Loop through all DocuWorks document pages and obtain the DocuWorks document page size.
[0018] 2.3. Compare the page size of each DocuWorks document page with the page size of the A3 file and the page size of the A4 file.
[0019] 2.4. If the page size of a DocuWorks document is the same as the page size of an A3 file or an A4 file, the page size of the DocuWorks document is the standard size.
[0020] 2.5. If the page size of a DocuWorks document is different from the page size of an A3 file and the page size of an A4 file, the page size of the DocuWorks document is a non-standard size.
[0021] S3. If the DocuWorks document page sizes of all pages in the DocuWorks document are standard sizes, set the PDF virtual printer that comes with the DocuWorks software as the default printer to print the entire DocuWorks document.
[0022] S4. If there is a non-standard DocuWorks document page size in the DocuWorks document, single-page printing is performed to generate a single-page PDF, and then the single-page PDFs are merged into a complete PDF document.
[0023] 4.1. Use SDK: Xdwapiwn interface to split DocuWorks document into DocuWorks single-page files.
[0024] 4.1.1、Call the DocuWorks software SDK: Xdwapiwn interface in the C# program; 4.1.2、Define the DocuWorks document handle variable handle, define the DocuWorks document opening mode variable mode, set the DocuWorks document opening mode to update, and define the DocuWorks document information variable info; 4.1.3. Open the DocuWorks document through the XDW_OpenDocumentHandle interface and assign a value to the handle variable handle; 4.1.4. Assign the DocuWorks document information to the information variable info through the XDW_GetDocumentInformation interface; 4.1.5. Get the number of pages of a DocuWorks document from the DocuWorks document properties; 4.1.6. Loop from the first page to the last page, and save each DocuWorks document page as a DocuWorks single-page file named with the page number through the XDW_GetPage interface.
[0025] 4.2. Get the page size of a DocuWorks single-page document.
[0026] 4.3. Copy the registry key template file.
[0027] 4.4. Replace the page parameters in the registry key template file to modify the size and orientation of the DocuWorks single-page document.
[0028] 4.4.1. Convert the page height key value into the page height in millimeters and take the integer part to obtain the first page height value n22. The remaining decimal part of the page height is rounded off and magnified by 10 times to obtain the second page height value n21. 4.4.2. Convert the page width key value into the page width in millimeters and take the integer part to obtain the first page width value n12. Round off the remaining decimal part of the page width and magnify it by 10 times to obtain the second page width value n11. 4.4.3. Convert the first page height value n22, the second page height value n21, the first page width value n12, and the second page width value n11 into hexadecimal to obtain a hexadecimal first page height value n4, a hexadecimal second page height value n3, a hexadecimal first page width value n2, and a hexadecimal second page width value n1; 4.4.4、Define the first string replace1=n1、n2、n3、n4, and define the second string replace2=n3、n4、n1、n2; 4.4.5. If the page height key value is less than or equal to the page width key value, fill the first string replace1 into the registry replacement parameter PARTa; 4.4.6. If the page height key value is greater than the page width key value, the second string replace2 is filled into the registry replacement parameter PARTa.
[0029] 4.5. Call batch processing to import the registry into the system.
[0030] Create a batch file input.bat in the system. The content of the batch file input.bat is: regedit / s C:\regedit\new.reg, where new.reg is the reg file with replaced parameter PARTa. Run Process.Start(@"C:\regedit\input.bat") in the C# program.
[0031] 4.6. Set the PDF virtual printer that comes with the DocuWorks software as the default printer, print the current DocuWorks single-page file to obtain a PDF single-page file and name the PDF single-page file with the page number.
[0032] 4.7. Store the PDF single-page files into the PDF document array in the order of naming.
[0033] 4.8. Use the control to synthesize the printed PDF single-page files into a complete PDF document according to the PDF document array.
[0034] Use the MergeFiles interface of the spire control to merge all the PDF single-page documents in the PDF document array into a complete PDF document in the order of naming.
[0035] The present invention provides a method for converting a DocuWorks document into a PDF document. The method comprises the following steps: splitting a DocuWorks document and determining whether it is of a non-standard size. For a non-standard size page, an interface is called to modify a registry parameter to realize the conversion of the non-standard size page. Then, the non-standard size page is printed in a single page. The method realizes the automatic conversion of the DocuWorks document of a non-standard size page into the original size of a PDF document, improves the document conversion efficiency, and solves the problem of size distortion in multi-page conversion in the prior art.
[0036] The above is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technician familiar with this profession can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent replacement and improvement made to the above embodiments without departing from the content of the technical solution of the present invention, based on the technical essence of the present invention, within the spirit and principles of the present invention, still fall within the protection scope of the technical solution of the present invention.
Claims
1. A method for converting a DocuWorks document into a PDF document, characterized in that The following steps are involved: S1. Find the list of drawings that need to be converted by reading the database, and wait for conversion in sequence in a queue; S2. Obtain the number of pages of the DocuWorks document through the interface provided in the DocuWorks software operation SDK, loop through all the pages of the DocuWorks document and obtain the page sizes of all the DocuWorks documents, and determine whether the page size of each DocuWorks document page is a standard size; S3. If the DocuWorks document page sizes of all pages in the DocuWorks document are standard sizes, set the PDF virtual printer provided by the DocuWorks software as the default printer to print the entire DocuWorks document; S4. If there is a non-standard DocuWorks document page size in the DocuWorks document, single-page printing is performed to generate a single-page PDF, and then the single-page PDFs are merged into a complete PDF document.
2. The method for converting a DocuWorks document into a PDF document according to claim 1, characterized in that: The step S2 specifically comprises: 2.
1. Obtain the number of pages of the DocuWorks document through the interface provided in the DocuWorks software operation SDK; 2.
2. Loop through all DocuWorks document pages and obtain the DocuWorks document page size; 2.
3. Compare the page size of each DocuWorks document page with the page size of the A3 file and the page size of the A4 file; 2.
4. If the page size of a DocuWorks document is the same as that of an A3 file or an A4 file, the page size of the DocuWorks document is the standard size. 2.
5. If the page size of a DocuWorks document is different from the page size of an A3 file and the page size of an A4 file, the page size of the DocuWorks document is a non-standard size.
3. The method for converting a DocuWorks document into a PDF document according to claim 1, characterized in that: The step S4 is specifically as follows: 4.
1. Use SDK: Xdwapiwn interface to split DocuWorks document into DocuWorks single-page files; 4.
2. Get the page size of a DocuWorks single-page document; 4.
3. Copy the registry key template file; 4.
4. Replace the page parameters in the registry key template file to modify the size and orientation of the DocuWorks single-page document; 4.
5. Call batch processing to import the registry into the system; 4.
6. Set the PDF virtual printer that comes with the DocuWorks software as the default printer, print the current DocuWorks single-page file to obtain a PDF single-page file and name the PDF single-page file with the page number; 4.
7. Store the PDF single-page files into the PDF document array in the order of naming; 4.
8. Use the control to synthesize the printed PDF single-page files into a complete PDF document according to the PDF document array.
4. The method for converting a DocuWorks document into a PDF document according to claim 3, characterized in that: The step 4.1 is specifically as follows: 4.1.1、Call the DocuWorks software SDK: Xdwapiwn interface in the C# program; 4.1.2、Define the DocuWorks document handle variable handle, define the DocuWorks document opening mode variable mode, set the DocuWorks document opening mode to update, and define the DocuWorks document information variable info; 4.1.
3. Open the DocuWorks document through the XDW_OpenDocumentHandle interface and assign a value to the handle variable handle; 4.1.
4. Assign the DocuWorks document information to the information variable info through the XDW_GetDocumentInformation interface; 4.1.
5. Get the number of pages of a DocuWorks document from the DocuWorks document properties; 4.1.
6. Loop from the first page to the last page, and save each DocuWorks document page as a DocuWorks single-page file named with the page number through the XDW_GetPage interface.
5. The method for converting a DocuWorks document into a PDF document according to claim 3, wherein: the step 4.4 specifically comprises: 4.4.
1. Convert the page height key value into the page height in millimeters and take the integer part to obtain the first page height value n22. The remaining decimal part of the page height is rounded off and magnified by 10 times to obtain the second page height value n21. 4.4.
2. Convert the page width key value into the page width in millimeters and take the integer part to obtain the first page width value n12. Round off the remaining decimal part of the page width and magnify it by 10 times to obtain the second page width value n11. 4.4.
3. Convert the first page height value n22, the second page height value n21, the first page width value n12, and the second page width value n11 into hexadecimal to obtain a hexadecimal first page height value n4, a hexadecimal second page height value n3, a hexadecimal first page width value n2, and a hexadecimal second page width value n1; 4.4.4、Define the first string replace1=n1、n2、n3、n4, and define the second string replace2=n3、n4、n1、n2; 4.4.
5. If the page height key value is less than or equal to the page width key value, fill the first string replace1 into the registry replacement parameter PARTa; 4.4.
6. If the page height key value is greater than the page width key value, the second string replace2 is filled into the registry replacement parameter PARTa.
6. The method for converting a DocuWorks document into a PDF document according to claim 3, characterized in that: Specifically, the step 4.5 is to create a batch file input.bat in the system, the content of the batch file input.bat is: regedit / s C:\regedit\new.reg, where new.reg is the reg file of the replaced parameter PARTa, and run Process.Start(@"C:\regedit\input.bat") in the C# program.
7. The method for converting a DocuWorks document into a PDF document according to claim 3, characterized in that: Specifically, step 4.8 uses the MergeFiles interface of the spire control to merge all the PDF single-page documents in the PDF document array into a complete PDF document in the order of naming.
Citation Information
Patent Citations
Data conversion apparatus, printing apparatus, and data conversion method
CN101794200A
Generation method and generation system of PDF (Portable Document Format) documents
CN102929848A
File management apparatus and non-transitory computer readable medium
CN113326229A
Document processing method, electronic equipment and storage medium
CN114118011A
Method for converting multiple drawings into multiple PDF drawings in same canvas of DWG
CN115061980A