C# .NET - Selecting a printer dynamically and sending a pdf to print in that sel

Asked By Eddy Lino on 15-May-12 10:22 AM
Earn up to 10 extra points for answering this tough question.
I need to select a printer at runtime and send the pdf to the selected printer
[)ia6l0 iii replied to Eddy Lino on 15-May-12 10:34 PM
C# or .Net does not have native support for this. You need to either invoke commands on Adobe PDF reader or use third party components like Aspose or GSPrint

Or you could try this technique. 

Get the list of installed printers from the PrinterSettings.InstalledPrinters and show them in a dropdown. This is available in the System.Drawing.Printing namespace. And then drop the pdf to the print folder of the chosen printer. For the latter, the code samples can be found at http://geekswithblogs.net/bleepzter/archive/2008/10/09/printing-a-pdf-file-to-a-network-printer-with-c.aspx

Hope this helps.
Eddy Lino replied to [)ia6l0 iii on 16-May-12 03:17 AM
I want to select a printer from my network ... I need to give the name in my code .... Ant help...
help
hi. how do i open a file from a path and send it to the pdf printer and by passing the Save As dialogue box by setting the default values in the add MIcrosoft CommonDialog Control 6.0 named:CommonDialog1 > Go to Reference and add Microsft Scripting Runtime - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Clicking Command1 will allow you to open a Text File and Command2 will allow you choose the PDF Printer. - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - [CODE] Option Explicit Dim fs As New FileSystemObject 'General Declaration Section Dim currentfile As String Private Sub Command2_Click() 'shows all printers CommonDialog1.ShowPrinter 'contents of Text1 is passed to the printer Printer.Print Text1 Printer.EndDoc End Sub [ / CODE] Set the MultiLine property of the Textbox
Hi, Is this possible to convert our .aspx page to pdf file at runtime.? if so, pls tell how to do this? but the pdf file should consist of multiple pages. thanks and regards, kiruba.e Try this code- string name = "test.pdf" ; FileStream fs = new FileStream ( Server . MapPath ( "~ / " ) + name , FileMode . Create , FileAccess . Write ); StreamWriter sw = new StreamWriter of a page: Response . AddHeader ( "Content-Disposition" , "attachment; filename = " + Server . UrlEncode ( name ) ); Response . ContentType = "application / pdf" ; / / Response.AddHeader ( "Content-Type", "binary / octet-stream" ); / / Response.AddHeader ( "Content-Disposition", "attachment; filename = " + downloadName + "; size End ( ); Try this and let me know. wil it show in a single page of pdf? I use the Winnovative.WnvHtmlConvert; You can find it and download the wnvhtmlconvert.dll. Make
Using: AC2003 & Adobe Acrobat Pro I have come up with a way to print report(s) by setting the Print Object default for each desired output Report to PDF Printer and using: DoCmd.OpenReport "MyReport", acViewNormal This accomplishes the desired results with user interface REQUIRED the dialogs. Newer versions are more difficult to deal with. Most people either use the PDF routine at http: / / www.lebans.com / reporttopdf.htm or control the registry settings and use a PDF printer driver of their choice. I like win2pdf. There are a bunch of PDF printer drivers. I have samples of registry controlling code in the Email module at www.rptsoftware
scan & save as PDF in c# C# .NET 28-Oct-12 08:07 PM How to scan the file & save as in PDF format using C# 2008. Plz give me an idea or code. very urgent The idea talk to the scanner, initiate the scan process and direct the scanner output to a pdf file. It isn't something that can be done overnight. And there are quire a com / KB / showcase / ScanCleanOCRSave.aspx. It is developed using EADTools Document Imaging Suite with OCR runtime . IM using the TWAIN Scanner & gdiplus.dll only but it is not allow to save as in PDF format. Showing an error unknown format picture. Code: public static bool SaveDIBAs(string picname, IntPtr pixdat) { SaveFileDialog sd = new SaveFileDialog (); sd . FileName = picname ; sd . Title = "Save bitmap as. . ." ; sd . Filter = "PDF (*.pdf) | *.pdf" ; sd . Filter = "Bitmap file (*.bmp) | *.bmp | TIFF file (*.tif) | *.tif | JPEG file (*.jpg) | *.jpg | PNG
Greetings community at large. I have a c# app that generates a PDF file. I have a printer that prints PDF natively. But I cannot figure out how to programatically print in C# . . . I can generate the PDF as a file or a stream . . but cannot figure out how to send either to the printer. the only events I can use seem to be e.Graphics.DrawImage( ) or e.Graphics.DrawString( ) is there a way to print a stream to a printer ? or a streamReader or binaryStream ? I thought that as a PDF is 'kind-of' a postscript file I could use e.Graphics.DrawString( ) . . not surprisingly I
Hello, I've looked through the web to learn that if I want to convert Excel to PDF and give it a specific name (automatically) through macro I should use . . .printout PrintToFile: = True, PRtoFileName: = "I / . . . . xx.pdf" But there's an error accessing the created pdf. It's all due to PrintToFile functionality. If I change destination file name extension to adobe acrobat file. It's there a more direct way to create from excel to pdf and having file name as variable? My intention is to create batches of pdfs from emailing out to people. I want to skip the step of converting from .prn to .pdf (haven't figured how I would do it). Thanks, Carmen Excel Programming Discussions ActiveSheet.PrintOut ActivePrinter (1) Macro (1) PrintToAnotherPrinter (1) PRtoFileName (1) PDFCreator (1) Microsoft does not support the PDF conversion. However, they recommend a service to do it. There are several with free downloadable converters. Google the web for Excel to PDF converter. It can be done e.g. with Bullzip PDF printer - www.bullzip.com. I
When the printer that a report was previously formatted for cannot be found, Access displays a message box asking if I want to use the default printer. When I OK this the report is displayed on the screen and I can then only applies to an mde. If an mdb is being used Access remembers the new printer selection. Is there a fix that can be applied to force an mde to remember the printer selection? Access Discussions Albert D. Kallal (1) Series (1) Describe (1) Application (1) Report (1 The Printer (1) Access (1) Printer selection (1) I have not tried this, but probably not. This would require a change report, and that cannot be done in a compiled version. You could keep the new printer in some table, and use the Printer object to redirect the printout, but that is
I have an Access 2000 backend db with a frontend 2000 mde db. Reports printing to a user selected printer are picking up the print settings (paper width and length) from the PC's default printer. So a report that should be printing on A4 is printing in the top left several pages, the same size of the labels. The application prints labels to the default printer (usually a Zebra with 1 label on a continuous roll). It also prints several reports in preview with the printer dialogue box for the user to choose which printer for the report, using this code. DoCmd.OpenReport sWhichReport, acViewPreview, sOpenArgs 'Open the report with acCmdPrint DoCmd.Close acReport, sWhichReport, acSaveNo 'Close the report The reports have Page Setup Default Printer selected. After reading posts on this site I removed the Track name AutoCorrect option from clients with Access 2003 print the labels successfully, print a manifest report to a selected printer on A4 correctly, then send a snp file of another report using the following code
Hello, I am going to be using a Symbol WT4090 to scan items. I need to printer a tag from the Zebra ql320 plus. I am trying to do this is Visual 1) AllocHGlobal (1) After you scaned an item you need to print it on an Printer? Depends on how you can connect to the printer. If the printer is connected to one PC you have to send Raw Bytes to the Printer. But therefore you need to have one template written in ZPL (or what language your printer 'speaks') I am using winspool.Drv to print to the printer. In this case i don't care if the printer is on Network or not