是否可以使用 Windows Spooler API 打印 PDF 文件。我尝试使用下面的代码,但它不工作......
int print_handle = 0;
OpenPrinter(pPrinterName, &print_handle, NULL);
if (print_handle == 0)
{
return 0;
}
docinfo1.pDocName = (LPTSTR)("My PDF");
docinfo1.pOutputFile = NULL;
docinfo1.pDatatype = (LPTSTR)("RAW");
temp = StartDocPrinter(print_handle, 1, &docinfo1);
temp = StartPagePrinter(print_handle);
temp = WritePrinter(print_handle, (LPBYTE)filebuff, filelen, &bytes_written);
EndPagePrinter(print_handle);
EndDocPrinter(print_handle);
WritePrinter 函数返回 SUCCESS 并且没有打印任何内容。使用此 API 打印 TXT 和 PRN 文件正在工作。