
Lstrcpy(buffer, TEXT( " C:\\UTReportPrerequisite\\gs\\gs8.53\\lib C:\\" " UTReportPrerequisite\\gs\\fonts C:\\UTReportPrerequisite" " \\gs\\gs8.53\\Resource")) RegSetValueEx(hkey, TEXT( " GS_DLL"), 0, REG_SZ, Lstrcpy(buffer, TEXT( " C:\\UTReportPrerequisite\\gs\\gs8.53\\bin\\gsdll32.dll")) Rc = RegCreateKey(HKEY_LOCAL_MACHINE, GHOSTSCRIPT_KEY2, &hkey) If ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, GHOSTSCRIPT_KEY2, 0, #define GHOSTSCRIPT_KEY2 TEXT("SOFTWARE\\AFPL Ghostscript\\8.53") RegSetValueEx(hkey, TEXT( " Delay"), 0, REG_DWORD, RegSetValueEx(hkey, TEXT( " RunUser"), 0, REG_DWORD, RegSetValueEx(hkey, TEXT( " ShowWindow"), 0, RegSetValueEx(hkey, TEXT( " Command"), 0, REG_SZ, Lstrcpy(buffer, " C:\\UTReportPrerequisite\\gs\\gs8.53\\bin\\gswin32c.exe") (CONST BYTE *)buffer, lstrlen(buffer)+1) RegSetValueEx(hkey, TEXT( " Arguments"), 0, REG_SZ, Rc = RegCreateKey(HKEY_LOCAL_MACHINE, PORT_KEY, &hkey) * failed to open key, so try to create it */ KEY_ALL_ACCESS, &hkey)) != ERROR_SUCCESS) If ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, PORT_KEY, 0, "Print\\Monitors\\Redirected Port\\Ports\\UTReportPDFPort:") #define PORT_KEY TEXT("SYSTEM\\ControlSet001\\Control\\"
PDFWRITER EXAMPLE DRIVER
Therefore, in our demo, we have to copy all the printer driver files from c:\\UTReportPrerequisite\\Driver to the folder returned by GetPrinterDriverDirectory. An application can retrieve the name of this directory by calling the GetPrinterDriverDirectory function.

Points of Interestīased on MSDN: Before an application calls the AddPrinterDriver function, all files required by the driver must be copied to the system's printer-driver directory. " Step5" to " Step8" let you have a chance to uninstall the printer you installed just now.
PDFWRITER EXAMPLE PDF
Check C:\SampleOut.PDF, which is your output PDF file.

Open WordPad.exe, type in whatever you want, then print it using " UTReport PDF Writer". Now is the right time to test our PDF writer. I want to point out here that " Step3" and " Step4" are a little bit time consuming so more patience should be paid. Clicking buttons from " Step1", " Step2", " Step3" to " Step4" sequentially, you will have a printer named " UTReport PDF Writer" installed if each step has been done successfully, as shown in the figure below. The demo project is very straightforward. The final folder structure should be like below: Instead, use WinRAR to unzip all files to “ c:\\UTReportPrerequisite\\Driver”. By chance, I chose HP color LaserJet 8550 PostScript driver. The last thing you need is a printer driver. There is a folder “ redmon17” in the demo project, please copy this folder to “ C:\\UTReportPrerequisite\\”.

You may download RedMon from its website, but I suggest you use a replacement that is packed in the demo project. You need to copy pdfwrite.rsp (a text file, which can be found in the demo project) to the folder as well. You are encouraged to use WinRAR or WinZip (I didn’t try WinZip) to unzip it to “ C:\\UTReportPrerequisite\\gs\\”.

Using the Code Before Jumping to the Demo Project
PDFWRITER EXAMPLE INSTALL
What you need to do is install a PostScript printer and let RedMon work as a bridge between the printer and Ghostscript.
PDFWRITER EXAMPLE HOW TO
The main purpose of this paper is to demonstrate how to create a PDF writer by using the Virtual Printer Method, which gives your applications an ability to generate PDF files through simply "printing".
