Author | Topic: How to print images, PDFs | |
---|---|---|
Jacob John | How to print images, PDFs on Sat, 11 Aug 2018 16:56:37 +0530 Hi, In my application, there is an "Attachments" button in Employee Master. Users can an any type of file through this button. They can view that file also. They can open it and print it through its application. Eg. if they click on a PDF file, Acrobat Reader will open and print that file from Acrobat Reader. Now, they want a facility to "Pint all Attachments" option. Means when they click this button all the files shold directed to the default or a selected printer without opening the relevant application. Attached files can be JPG,BMP,PDF,DOC,XLS etc. How can we do that ? Regards Kiron | |
Jonathan Leeming | Re: How to print images, PDFs on Sat, 11 Aug 2018 12:35:02 -0600 On 8/11/2018 5:26 AM, Jacob John wrote: > Hi, > > In my application, there is an "Attachments" button in Employee > Master. Users can an any type of file through this button. They can > view that file also. They can open it and print it through its > application. > > Eg. if they click on a PDF file, Acrobat Reader will open and print > that file from Acrobat Reader. > > Now, they want a facility to "Pint all Attachments" option. Means when > they click this button all the files shold directed to the default or > a selected printer without opening the relevant application. Attached > files can be JPG,BMP,PDF,DOC,XLS etc. > > How can we do that ? > > Regards > Kiron > Hi Kiron, I use Clayton's Topdown libabry and it includes a function called tdRunShell. Here is an portion of the description... tdRunShell() is a wrapper for the Win32 API function ShellExecuteA. It can be used to run applications from within an Xbase++ program and offers an alternative to the Xbase++ RunShell() function (see Note #6 below). tdRunShell can also send a document to the default printer. Not knowing if you have a copy of the TopDown Library which Clayton made public upon his passing I have attached a test prg file that contains a slightly modified version of his tdRunShell() along with a very short application that prints a selection of file types using the associated applications. For printing images I normally use Clayton's Printer class which has a method: METHOD PrImage print image file JPG,BMP,GIF,PNG Hope this helps a bit... Jonathan jonathan.leeming@the-family-centre.com Edmonton, Alberta, Canada printdocs.prg | |
Jim Lee | Re: How to print images, PDFs on Sat, 11 Aug 2018 23:42:09 +0200 > How can we do that ? FUNCTION ShellOpenPrint(cPath,cFile) #define SW_HIDE 0 #define SW_NORMAL 1 lSuccess := DllCall( "SHELL32.DLL" , DLL_STDCALL, ; "ShellExecuteA", AppDesktop():GetHWND(), "print",; cPath+cFile, NIL, CurDir(), SW_NORMAL ) | |
Jacob John | Re: How to print images, PDFs on Mon, 13 Aug 2018 17:34:25 +0530 Hi, Thanks for the both suggestions. In both cases, print dialog window is pop up. Is there any to avoid print dialog and print continously ? Regards Kiron On Sat, 11 Aug 2018 23:42:09 +0200, Jim Lee wrote: >> How can we do that ? > >FUNCTION ShellOpenPrint(cPath,cFile) > #define SW_HIDE 0 > #define SW_NORMAL 1 > > lSuccess := DllCall( "SHELL32.DLL" , DLL_STDCALL, ; > "ShellExecuteA", AppDesktop():GetHWND(), "print",; > cPath+cFile, NIL, CurDir(), SW_NORMAL ) > | |
Jim Lee | Re: How to print images, PDFs on Mon, 13 Aug 2018 20:13:53 +0200 have you try SW_HIDE instead of SW_NORMAL ? | |
Jonathan Leeming | Re: How to print images, PDFs on Mon, 13 Aug 2018 12:40:15 -0600 On 8/13/2018 12:13 PM, Jim Lee wrote: > have you try SW_HIDE instead of SW_NORMAL ? > > Hi Jim, Using my test routine that I uploaded previously which uses the same ShellExecuteA as you suggested I modified it to use SW_HIDE but still found that you can see Excel / Word load and unload while Adobe loads and stays loaded. Regards... Jonathan jonathan.leeming@the-family-centre.com Edmonton, Alberta, Canada | |
Edgar Borger | Re: How to print images, PDFs on Mon, 13 Aug 2018 10:06:35 -0300 Hello, please have a look at our XbpPDF class available for download at http://www.borger.com.br/softsupply it has among other things, a View() and a Print() method that you use to view and/or print PDF documents from Xbase programs. Best regards, Edgar Em 11/08/2018 08:26, Jacob John escreveu: > Hi, > > In my application, there is an "Attachments" button in Employee > Master. Users can an any type of file through this button. They can > view that file also. They can open it and print it through its > application. > > Eg. if they click on a PDF file, Acrobat Reader will open and print > that file from Acrobat Reader. > > Now, they want a facility to "Pint all Attachments" option. Means when > they click this button all the files shold directed to the default or > a selected printer without opening the relevant application. Attached > files can be JPG,BMP,PDF,DOC,XLS etc. > > How can we do that ? > > Regards > Kiron > Edgar Borger Softsupply Informatica Ltda. Rua Alagoas, 48 Sao Paulo, SP 01242-000 Tel : (5511) 3159-1997 Email : softsupply@terra.com.br | |
Jonathan Leeming | Re: How to print images, PDFs on Mon, 13 Aug 2018 09:43:05 -0600 On 8/11/2018 5:26 AM, Jacob John wrote: > Hi, > > In my application, there is an "Attachments" button in Employee > Master. Users can an any type of file through this button. They can > view that file also. They can open it and print it through its > application. > > Eg. if they click on a PDF file, Acrobat Reader will open and print > that file from Acrobat Reader. > > Now, they want a facility to "Pint all Attachments" option. Means when > they click this button all the files shold directed to the default or > a selected printer without opening the relevant application. Attached > files can be JPG,BMP,PDF,DOC,XLS etc. > > How can we do that ? > > Regards > Kiron > Hi Kiron, The ShellExecuteA approach that I and Jim suggested simply rely on Windows to use the associated application to print. Definitely a simple approach but should you want a "quieter" process then you could create a number of functions to be called depending on the file extension. I can certainly endorse Edgars xbpPDF library as I use it a fair bit and it is simple to use. A few lines of code would print your PDF. For Excel & Word files you could use activex to open and print the files. As for image files, as I stated earlier, I use Clayton's TopDown Library to print. Now in public domain... Thanks Clayton! So, certainly it should be possible to print the file types you listed without popups. Regards... Jonathan jonathan.leeming@the-family-centre.com Edmonton, Alberta, Canada | |
Jacob John | Re: How to print images, PDFs on Tue, 14 Aug 2018 13:54:19 +0530 Hi Jim/Jonathan/Edgar, I tried SW_HIDE. But same result. When went through MS Forums, understands that, ShellExecuteA() just send an instruction to the corresponding application. And the application decides how it should handle it. So i think think, to acheive my requirement, it will better to write our own functions as suggested by Jonathan. But my problem is user can add any type of file to the attachment. So decided to address the printing issue in case of common file types like PDF,BMP,JPG,XLS etc. Thanks you all for the suggestions. Regards Kiron On Mon, 13 Aug 2018 09:43:05 -0600, Jonathan Leeming wrote: >On 8/11/2018 5:26 AM, Jacob John wrote: >> Hi, >> >> In my application, there is an "Attachments" button in Employee >> Master. Users can an any type of file through this button. They can >> view that file also. They can open it and print it through its >> application. >> >> Eg. if they click on a PDF file, Acrobat Reader will open and print >> that file from Acrobat Reader. >> >> Now, they want a facility to "Pint all Attachments" option. Means when >> they click this button all the files shold directed to the default or >> a selected printer without opening the relevant application. Attached >> files can be JPG,BMP,PDF,DOC,XLS etc. >> >> How can we do that ? >> >> Regards >> Kiron >> >Hi Kiron, > >The ShellExecuteA approach that I and Jim suggested simply rely on >Windows to use the associated application to print. Definitely a simple >approach but should you want a "quieter" process then you could create a >number of functions to be called depending on the file extension. > >I can certainly endorse Edgars xbpPDF library as I use it a fair bit and >it is simple to use. A few lines of code would print your PDF. > >For Excel & Word files you could use activex to open and print the files. > >As for image files, as I stated earlier, I use Clayton's TopDown Library >to print. Now in public domain... Thanks Clayton! > >So, certainly it should be possible to print the file types you listed >without popups. > >Regards... Jonathan | |
Jonathan Leeming | Re: How to print images, PDFs on Tue, 14 Aug 2018 10:04:46 -0600 On 8/14/2018 2:24 AM, Jacob John wrote: > Hi Jim/Jonathan/Edgar, > > I tried SW_HIDE. But same result. > > When went through MS Forums, understands that, ShellExecuteA() just > send an instruction to the corresponding application. And the > application decides how it should handle it. > > So i think think, to acheive my requirement, it will better to write > our own functions as suggested by Jonathan. > > But my problem is user can add any type of file to the attachment. So > decided to address the printing issue in case of common file types > like PDF,BMP,JPG,XLS etc. > > Thanks you all for the suggestions. > > Regards > Kiron > > > On Mon, 13 Aug 2018 09:43:05 -0600, Jonathan Leeming wrote: > >> On 8/11/2018 5:26 AM, Jacob John wrote: >>> Hi, >>> >>> In my application, there is an "Attachments" button in Employee >>> Master. Users can an any type of file through this button. They can >>> view that file also. They can open it and print it through its >>> application. >>> >>> Eg. if they click on a PDF file, Acrobat Reader will open and print >>> that file from Acrobat Reader. >>> >>> Now, they want a facility to "Pint all Attachments" option. Means when >>> they click this button all the files shold directed to the default or >>> a selected printer without opening the relevant application. Attached >>> files can be JPG,BMP,PDF,DOC,XLS etc. >>> >>> How can we do that ? >>> >>> Regards >>> Kiron >>> >> Hi Kiron, >> >> The ShellExecuteA approach that I and Jim suggested simply rely on >> Windows to use the associated application to print. Definitely a simple >> approach but should you want a "quieter" process then you could create a >> number of functions to be called depending on the file extension. >> >> I can certainly endorse Edgars xbpPDF library as I use it a fair bit and >> it is simple to use. A few lines of code would print your PDF. >> >> For Excel & Word files you could use activex to open and print the files. >> >> As for image files, as I stated earlier, I use Clayton's TopDown Library >> to print. Now in public domain... Thanks Clayton! >> >> So, certainly it should be possible to print the file types you listed >> without popups. >> >> Regards... Jonathan Hi Kiron, Edgar's website has a Demo version that I believe is full featured and puts "DEMO" across anything produced so I should think it should be easy to test. I don't know if you have used activex from within Xbase but it is easy to use... let me know if you need more on this. Handling images may be a little more involved but Xbase has all you need. I'm guessing that you could create 4 routines to be used for PDF, Word, Excel & images with a 5th that would use ShellExecuteA() for exceptions. Regards... Jonathan jonathan.leeming@the-family-centre.com Edmonton, Alberta, Canada | |
Carlos a Beling | Re: How to print images, PDFs on Wed, 15 Aug 2018 09:33:44 -0300 Hello goodmorning. In ShellExecuteA (https://docs.microsoft.com/en-us/windows/desktop/shell/launch) it has a documentation as the attached file. Could it to be useful for you? Fraternally Beling Em 14/08/2018 13:04, Jonathan Leeming escreveu: > On 8/14/2018 2:24 AM, Jacob John wrote: >> Hi Jim/Jonathan/Edgar, >> >> I tried SW_HIDE. But same result. >> >> When went through MS Forums, understands that, ShellExecuteA() just >> send an instruction to the corresponding application. And the >> application decides how it should handle it. >> >> So i think think, to acheive my requirement, it will better to write >> our own functions as suggested by Jonathan. >> >> But my problem is user can add any type of file to the attachment. So >> decided to address the printing issue in case of common file types >> like PDF,BMP,JPG,XLS etc. >> >> Thanks you all for the suggestions. >> >> Regards >> Kiron >> >> >> On Mon, 13 Aug 2018 09:43:05 -0600, Jonathan Leeming wrote: >> >>> On 8/11/2018 5:26 AM, Jacob John wrote: >>>> Hi, >>>> >>>> In my application, there is an "Attachments" button in Employee >>>> Master. Users can an any type of file through this button. They can >>>> view that file also. They can open it and print it through its >>>> application. >>>> >>>> Eg. if they click on a PDF file, Acrobat Reader will open and print >>>> that file from Acrobat Reader. >>>> >>>> Now, they want a facility to "Pint all Attachments" option. Means when >>>> they click this button all the files shold directed to the default or >>>> a selected printer without opening the relevant application. Attached >>>> files can be JPG,BMP,PDF,DOC,XLS etc. >>>> >>>> How can we do that ? >>>> >>>> Regards >>>> Kiron >>>> >>> Hi Kiron, >>> >>> The ShellExecuteA approach that I and Jim suggested simply rely on >>> Windows to use the associated application to print. Definitely a simple >>> approach but should you want a "quieter" process then you could create a >>> number of functions to be called depending on the file extension. >>> >>> I can certainly endorse Edgars xbpPDF library as I use it a fair bit and >>> it is simple to use. A few lines of code would print your PDF. >>> >>> For Excel & Word files you could use activex to open and print the >>> files. >>> >>> As for image files, as I stated earlier, I use Clayton's TopDown Library >>> to print. Now in public domain... Thanks Clayton! >>> >>> So, certainly it should be possible to print the file types you listed >>> without popups. >>> >>> Regards... Jonathan > Hi Kiron, > > Edgar's website has a Demo version that I believe is full featured and > puts "DEMO" across anything produced so I should think it should be easy > to test. I don't know if you have used activex from within Xbase but it > is easy to use... let me know if you need more on this. > > Handling images may be a little more involved but Xbase has all you need. > > I'm guessing that you could create 4 routines to be used for PDF, Word, > Excel & images with a 5th that would use ShellExecuteA() for exceptions. > > Regards... Jonathan > _open.png | |
Edgar Borger | Re: How to print images, PDFs on Sun, 19 Aug 2018 12:50:14 -0300 as Jonathan said, you can use our XbpPDF class for the PDF files, and use plain xbase for image (bmp, jpg, png) files, you just have to check the file type and call the routine you need for each one of them. Regards, Edgar Em 14/08/2018 05:24, Jacob John escreveu: > Hi Jim/Jonathan/Edgar, > > I tried SW_HIDE. But same result. > > When went through MS Forums, understands that, ShellExecuteA() just > send an instruction to the corresponding application. And the > application decides how it should handle it. > > So i think think, to acheive my requirement, it will better to write > our own functions as suggested by Jonathan. > > But my problem is user can add any type of file to the attachment. So > decided to address the printing issue in case of common file types > like PDF,BMP,JPG,XLS etc. > > Thanks you all for the suggestions. > > Regards > Kiron > > > On Mon, 13 Aug 2018 09:43:05 -0600, Jonathan Leeming wrote: > >> On 8/11/2018 5:26 AM, Jacob John wrote: >>> Hi, >>> >>> In my application, there is an "Attachments" button in Employee >>> Master. Users can an any type of file through this button. They can >>> view that file also. They can open it and print it through its >>> application. >>> >>> Eg. if they click on a PDF file, Acrobat Reader will open and print >>> that file from Acrobat Reader. >>> >>> Now, they want a facility to "Pint all Attachments" option. Means when >>> they click this button all the files shold directed to the default or >>> a selected printer without opening the relevant application. Attached >>> files can be JPG,BMP,PDF,DOC,XLS etc. >>> >>> How can we do that ? >>> >>> Regards >>> Kiron >>> >> Hi Kiron, >> >> The ShellExecuteA approach that I and Jim suggested simply rely on >> Windows to use the associated application to print. Definitely a simple >> approach but should you want a "quieter" process then you could create a >> number of functions to be called depending on the file extension. >> >> I can certainly endorse Edgars xbpPDF library as I use it a fair bit and >> it is simple to use. A few lines of code would print your PDF. >> >> For Excel & Word files you could use activex to open and print the files. >> >> As for image files, as I stated earlier, I use Clayton's TopDown Library >> to print. Now in public domain... Thanks Clayton! >> >> So, certainly it should be possible to print the file types you listed >> without popups. >> >> Regards... Jonathan |