Hi,
I have downloaded the Tracker X Change SDK and running the C Example. What I want is an example in C/C++ which can print the PDF silently. I know that the .net example can do the same, but I want it in the C/C++ language. If you have such an example, can you please share it? Just silent print functionality using pxcview.dll in C/C++ would be perfect.
Thanks in advance.
Regards,
Prateek Kothari
Silent Print PDF using C/C++
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Silent Print PDF using C/C++
We do have a C++ sample showing printing a PDF - see pxcview36_sample_app in the Examples directory.
Essentially you must use the windows API to create a printer device context and then render the PDF to it with PXCV_DrawPageToDC().
Look for the function "void PrintPdfFile(HWND hParentWnd)" in the example application (pxcview36_sample_app.cpp) for more details.
Hope this helps.
-Walter
Essentially you must use the windows API to create a printer device context and then render the PDF to it with PXCV_DrawPageToDC().
Look for the function "void PrintPdfFile(HWND hParentWnd)" in the example application (pxcview36_sample_app.cpp) for more details.
Hope this helps.
-Walter
-
- User
- Posts: 8
- Joined: Wed Sep 07, 2011 6:02 pm
Re: Silent Print PDF using C/C++
Thanks for the quick response!!
Yes, I see the PrintPdfFile(HWND hParentWnd), but in the example the function PrintPdfFile() takes in the handle to the parent window which has the PDF opened. What I want is the function PrintPdfFile(HWND hParentWnd) converted to something like PrintPdfFile(string pdfPath, string printerName) which takes in the pdf path and Printer Name as input and prints the pdf silently without opening the print dialog. Can you guide me how to convert the function PrintPdfFile(HWND hParentWnd) to print the PDF silently.
Thank You.
Regards,
Prateek Kothari
Yes, I see the PrintPdfFile(HWND hParentWnd), but in the example the function PrintPdfFile() takes in the handle to the parent window which has the PDF opened. What I want is the function PrintPdfFile(HWND hParentWnd) converted to something like PrintPdfFile(string pdfPath, string printerName) which takes in the pdf path and Printer Name as input and prints the pdf silently without opening the print dialog. Can you guide me how to convert the function PrintPdfFile(HWND hParentWnd) to print the PDF silently.
Thank You.
Regards,
Prateek Kothari
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Silent Print PDF using C/C++
To convert the function just use standard C++ and move the code that initializes the global variable "curDoc", and loads the PDF file, into the function. This code is in the existing sample function OpenPdfFile() and the most important SDK functions are PXCV_Init() and PXCV_ReadDocumentW().prateek wrote:Thanks for the quick response!!
Yes, I see the PrintPdfFile(HWND hParentWnd), but in the example the function PrintPdfFile() takes in the handle to the parent window which has the PDF opened. What I want is the function PrintPdfFile(HWND hParentWnd) converted to something like PrintPdfFile(string pdfPath, string printerName) which takes in the pdf path and Printer Name as input and prints the pdf silently without opening the print dialog. Can you guide me how to convert the function PrintPdfFile(HWND hParentWnd) to print the PDF silently.
Thank You.
Regards,
Prateek Kothari
Code: Select all
hr = PXCV_Init(&curDoc, NULL, NULL);
if (IS_DS_FAILED(hr))
break;
hr = PXCV_ReadDocumentW(curDoc, fname, 0);
if (hr == PS40_ERR_DocEncrypted)
[... etc....]
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
So long as you can create the printer device context to send to PXCV_DrawPageToDC(), you are golden!
Please note that you should use the correct flags pxvrm_Printing and pxvrpf_UseVectorRenderer for printing PDFs though (in the PXV_CommonRenderParameters structure you send to PXCV_DrawPageToDC()), as follows:
Code: Select all
PXV_CommonRenderParameters crp;
crp.Flags = pxvrpf_UseVectorRenderer;
crp.RenderTarget = pxvrm_Printing;
-
- Site Admin
- Posts: 5223
- Joined: Tue Jun 29, 2004 10:34 am
Re: Silent Print PDF using C/C++
Not quite complete - see the section in the API Manual ;
ShowSaveDialog
Boolean value
If this property is True, pdfSaver will display the Save As dialog where the path and file name of the PDF file must be specified.
Canceling the Save As dialog will cancel the PDF file creation.
Default value: True
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 8
- Joined: Wed Sep 07, 2011 6:02 pm
Re: Silent Print PDF using C/C++
Thanks!! I got the Silent printing working.
And now I want to change the printer settings like Paper Size, Paper source for the print job. Do I need to update the DEVMODE? I did wrote an update DEVMODE method which updates the printer settings. Now the question is from where I should call the update Devmode method? From the PrintPdfFile(HWND hParentWnd) method or even before calling PrintPdfFile(HWND hParentWnd) method?
Thank You.
Regards,
Prateek Kothari
And now I want to change the printer settings like Paper Size, Paper source for the print job. Do I need to update the DEVMODE? I did wrote an update DEVMODE method which updates the printer settings. Now the question is from where I should call the update Devmode method? From the PrintPdfFile(HWND hParentWnd) method or even before calling PrintPdfFile(HWND hParentWnd) method?
Thank You.
Regards,
Prateek Kothari
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Silent Print PDF using C/C++
I believe you are asking a question more related to windows programming than our SDK specifically; we unfortunately don't have the resources to answer all general programming questions. I would recommend searching MSDN for information on changing printer settings programatically, unless you are referring to our PDF-XChange drivers API, which I don't think you are.
You may want to start here:
http://support.microsoft.com/kb/167345
You may want to start here:
http://support.microsoft.com/kb/167345