Hi Julian,
i need to create a PDF file from a CAD dll. This CAD dll can print it's draw on a default printer or on a specific HDC.
Here my C++Builder function used for print from this CAD dll:
Code
bool __fastcall Tcad::PrintAll(HDC hPrintDC)
{
bool ok = false;
TCursor oldCur = Screen->Cursor;
Screen->Cursor = crHourGlass;
try
{
double x0, y0, x1, y1, xc, yc;
// get total draw extension
CadGetExtentRect ( hDwg, &x0, &y0, &x1, &y1 );
// define a part of drawing to print (coordinates at display projection)
CadPrintPutRect( x0, y0, x1, y1 );
// set print parameters so the entire drawing fits to printer paper
int w = x1 - x0;
int h = y1 - y0;
// define best orientation
if (w > h)
CadPrintPutOrient( CAD_PAPER_LANDSCAPE );
else
CadPrintPutOrient( CAD_PAPER_PORTRAIT );
int PaperW = CadPrintGetPaperW();
int PaperH = CadPrintGetPaperH();
double scx = PaperW / w;
double scy = PaperH / h;
double scale = min( scx, scy ) * 0.99;
// define an output scale 1:1
CadPrintPutScale( scale );
if ( hPrintDC )
{
// print on a specific printer
ok = CadPrint ( hDwg, false, hPrintDC );
}
else
{
// print on default printer
ok = CadPrint ( hDwg, false, 0 );
}
}
__finally
{
Screen->Cursor = oldCur;
return ok;
}
}
//---------------------------------------------------------------------------
Alles anzeigen
Can i use wPDF as a specific printer ?