Creating a PDF File (Using the Engine) New in Version 2025.1

www.CAD6.com

Once you started the CAD6engine and created drawing data (or had the user create/modify it by showing him the user interface), it is very simple to create a PDF file from it.

 

Here's the basic code:

 

C++ Source Code

MKI_PRINT_DATA cPrintData;

cPrintData.InitDirectPDF( L"C:\\Test.pdf", MKI_PAGETYPE_DIN_A4, false );

MKI_RESULTVALUE nResult = MKI_DrawingPrint( &cPrintData, true );

 

It tells the engine to create a PDF printing context that will output its data directly to the file C:\Test.pdf.

 

The result will be a PDF file with all the drawing. If the file C:\Test.pdf already existed before, it will be overwritten without a warning. All progress and error dialogs are suppressed. Modify any members of cPrintData as required.

 

If you require control over individual settings of the PDF printing device, you can create that separately using the following code:

 

C++ Source Code

MKI_PRINT_DEVICE cPrintDevice;

cPrintDevice.InitDirectPDF( L"C:\\Test.pdf" );

cPrintDevice.m_cPrintDirectPDF.SetPage( MKI_PAGETYPE_DIN_A4, false );

MKI_PrinterSetInfo( 0, cPrintDevice );

 

MKI_PRINT_DATA cPrintData;

cPrintData.Init();

MKI_RESULTVALUE nResult = MKI_DrawingPrint( &cPrintData, true );

 

It first tells the engine to create a PDF printing device that will output its data directly to the file C:\Test.pdf. To alter the settings used, modify the members of cPrintDevice as required. The result is set as current parameters for the first printer (index 0). Then, it creates a printing context that by default says to print all pages of the current drawing using the first printer (index 0). Again, modify any members of cPrintData as required.

 

The result will be the same as before.

 

CAD6interface 2026.0 - Copyright 2026 Malz++Kassner® GmbH