MDConvert

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Commands Reference > NeutralFormat >

MDConvert

Description

Converts an input .DWG, .ME, DOC(x), XLS(x) or image file (BMP, JPG, TIF) into a PDF file, or a PDF into an image file or DXF.

starting from build 20250813 PCX and TGA formats are not supported anymore

Syntax

call DBWShell("MDConvert  inputImageFilePath outputPdfFilePath [resolutionFactor] | [width],[height]")

Parameters

inputImageFilePath

the complete path of the image to convert

outputPdfFilePath

the complete path for the converted image

resolutionFactor

Optional. Available when converting from DWG to BMP only.

If set, the output will be a BMP file despite of the given file extension.

 

When a DWG file is converted, this parameter controls the final PDF resolution;

a value of 2.0 will double the default resolution (that is 1024x768 pixels and conrespond to a resolutionFactor = 1.0 )
the background color, for the DWG case is get from the option User Interface → Preview → Vectorial preview background color

to control dimensions of created PDF in a DGW to PDF conversion:

1.do not assign a resolution factor value

2.in case (for custom formats) use DBWDwg2PdfCustomSheetFormats.PAR file

3.in case (for plot syle) use DBWDwg2PdfPlotStyle.PAR file

4.in case (for further customization) use DBWDwg2PdfOptions.PAR file

width

Optional. Only if converting from PDF to an image.
it's the width of the generated image

height

Optional. Only if converting from PDF to an image
it's the height of the generated image

Results

@MDOKPDF

0: some errors has occurred in creating PDF
1:PDF properly generated

Remarks

The command attempts to create a PDF with exactly the same sheet size of the original DWG or ME being processed.

Starting from build 20050915, the conversion technology has been improved. Due to this enhancement, the optional parameter resolution is no more strictly necessary, unless you may want to continue the old conversion method, for which it is necessary to set it to a not null value ( example "1.0" )

Since this command and the Revision outputs functionality are based on the same mechanism, please consider topic Supported format conversions as valid also for MDConvert command.

Example

with resolution parameter

sub main()

        DBWInit(TRUE)
        fileDwg = "e:\test\dwg\2005-3V2LJ.dwg"
        filePdf = "e:\test\dwg\2005-3V2LJ.pdf"
        resolutionFactor = 2.0
        DBWShell("MDConvert " & replace(fileDwg," ","|") & " " & replace(filePdf," ","|") & " " & resolutionFactor)
end sub

without resolution parameter

Sub main()

 DBWinit(TRUE)
 dwgFileName = replace("o:\myfolder\test.DWG"," ","|")
 pdfFileName = replace("o:\myfolder\test.PDF"," ","|")
 DBWShell("MDConvert " & replace(fileDwg," ","|") & " " & replace(filePdf," ","|"))
End Sub
converting from a PDF to an image
Sub main()
 DBWinit(TRUE)
 pdfFileName = replace("E:\test\PDF\0061002354.SLDDRW.00.PDF"," ","|")
 jpgFileName = replace("E:\test\PDF\0061002354.JPG"," ","|")
 DBWShell("MDConvert " & replace(fileDwg," ","|") & " " & replace(filePdf," ","|") & " 512 384")
End Sub

RMB on a DWG in the tree, creates a PDF with the same name, beside the DWG.

sub main()

 DBWInit(TRUE)
 DBWShell("CurrentDocument")
 uid = DBWResult("@DOCUMENT_UNIQUE_ID")
 fdir = DBWQueryByUid(uid,DBWLookUp("NAME_FIELD_FILE_DIRECTORY"))
 fname = DBWQueryByUid(uid,DBWLookUp("NAME_FIELD_FILE_NAME"))
 fileDwg = fdir & fname
 filePdf = fdir & DBWFileNameNoExt1(fname) & ".pdf"
 DBWShell("MDConvert " & replace(fileDwg," ","|") & " " & replace(filePdf," ","|"))
end sub