

It is not just about software and suppose you write a document in a word processor and you use an unusual font that is only on your computer. If you then give the file to someone else, they would not be able to view it or print it unless they had the same software you have. Always monitor the print queue and end when there is no print task in the print queue.PDF is a clever solution to a problem and that is how to enable people to view and print documents on their computer when they do not have the software that created them.įor example, you could have a desktop publishing program and create a leaflet, manual, brochure, newsletter or some other publication. Printing.PrintQueue queue = prtSrv.GetPrintQueue( " Microsoft XPS Document Writer " ) * **** Track the printing status of the file in the printer queue, until the file is printed **** */ PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero) PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero) Send 2 messages to the save button to simulate the click message, Use this to press the save button HChild = FindWindowEx(hWnd, IntPtr.Zero, " Button ", " &Save " ) Find the save button in the dialog box SendMessage(hChild, WM_SETTEXT, IntPtr.Zero, xps_filepath) Send a message to the input box, fill the target xps file name HChild = FindWindowEx(hChild, IntPtr.Zero, " Edit ", String.Empty) // File name edit control HChild = FindWindowEx(hChild, IntPtr.Zero, " ComboBox ", String.Empty) HChild = FindWindowEx(hChild, IntPtr.Zero, " FloatNotifySink ", String.Empty) HChild = FindWindowEx(hChild, IntPtr.Zero, " DirectUIHWND ", String.Empty) HChild = FindWindowEx(hWnd, IntPtr.Zero, " DUIViewWndClassName ", String.Empty) Because the input box is nested by multiple controls, you need to find the input box in the control level by level IntPtr hWnd = FindWindow( " #32770 ", " Save File As " ) Find the window handle of the Save File As dialog box * **** Finally, by sending a message to the save button to press the save button in the dialog box******* ****************** */ * **** box The target xps file name, and finally by sending a message to the save button to ****** */ * **** So use Win32Api to find the file name input box in the Save File As dialog box, and automatically fill in the input box by sending a message to the input ***** */ ""Microsoft XPS Document Writer"" ", pdf_filepath)

Print function, print out the file, the code is listed below for reference.ĭevelopment environment: VS2010. After some investigation, you can directly use Adobe acro Reader or Foxit Reader to print. Windows printers are too troublesome to call. It’s easy to call this printer through a series of APIs, but I think The printer is also available, so the next question is how to call this printer. "SaveAsPDFandXPS.exe", after installing, there will be this printer.

You can download it from the Microsoft website If it is the XP system, it may not be available. The printer driver will be automatically installed when Office2007 is installed on the WIN7 system. West is to buy, you can experience the next trial version first.Ģ) Use the "Microsoft XPS Document Writer" printer to print the pdf as a local xps file to complete the conversion function. After a period of investigation,ġ) The conversion function can be easily completed by the third development component of PDFNet, and there are other functions for pdf file operation, which is still very powerful. The xps file is still new, so I don’t know much about it. I recently came across a project, which has a function that needs to convert a pdf file into an xps file.
