How to Print to Specific Printer using PrintAndExport?

2180
6
Jump to solution
07-14-2014 07:05 AM
Highlighted
New Contributor III


I can find examples of printing to the default printing but am having a difficult navigating the new site to find an example of printing a map layout to a user-selected printer that is not the default printer.

Can someone please help me with this? Thanks!

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor III


No, I meant printing from code (isn't this an ArcObjects.Net discussion group?)

I found the answer - I was making it much harder than it needed to be. All I had to do was this:

 

paper.PrinterName = strPrinterName

where strPrinterName is the name of the printer I want to print to, which may or may not be the default printer.

View solution in original post

Reply
0 Kudos
6 Replies
Highlighted
New Contributor III

Are you talking about causing a map to print from code, or are you talking about just printing from within ArcMap?

Assuming that you meant the latter, you click "Print..." to open the Print dialog. At the top of that dialog, it will show you the currently selected printer, which is likely your default printer. There's also a "Setup..." button in the top right. Click that and it'll bring up the "Page and Print Setup" dialog. At the top of that dialog is a drop down list that has all your installed printers listed. Use that to choose a different printer. You can then access the printer properties with the "Properties..." button, change the orientation, paper source, etc.

I'm using ArcMap 10.1, if that makes any difference, but I'm guessing it would be about the same for most any recent version.

Reply
0 Kudos
Highlighted
New Contributor III


No, I meant printing from code (isn't this an ArcObjects.Net discussion group?)

I found the answer - I was making it much harder than it needed to be. All I had to do was this:

 

paper.PrinterName = strPrinterName

where strPrinterName is the name of the printer I want to print to, which may or may not be the default printer.

View solution in original post

Reply
0 Kudos
Highlighted
New Contributor III

My apologies. I didn't see anything in your question that sounded like you were talking about code, so I just assumed you must have been talking about just printing from ArcMap - which is admittedly confusing as well, since you would normally expect to be able to select the printer straight from the Print dialog. LOL

I'm glad you were able to find the answer, but I have no idea what "paper" is in your code snippet.

Reply
0 Kudos
Highlighted
New Contributor III

Sorry - I was in a hurry when I wrote that and should have included more information.

I see now that my question itself didn't say anything about coding. Since PrintAndExport is an ArcObjects CoClass name and I included that in the subject line, I thought it would be understood that it was a coding question. I'll be more aware of being more clear in the future.

I should have included this in my earlier response as well - the line of code is from the ExportToActiveView ArcObjects sample found here: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000026000000

Reply
0 Kudos
Highlighted
New Contributor III

No problem. I didn't really notice the PrintAndExport part until after you posted your previous reply, and I'm just not that familiar with that area of ArcObjects to recognize it as such.

And my comment about the "paper" variable was just that I found it very comical that you explained what "strPrinterName" was, even though it would be fairly obvious to a programmer based on commonly used naming conventions, but that the "paper" variable, which doesn't have an obvious naming convention, was not explained. Though if I knew more about that area of ArcObjects, naming a variable "paper" and using that variable to define what printer you want to use, might not seem so weird.

Reply
0 Kudos
Highlighted
New Contributor III

I laughed out loud when I read your second paragraph!

And I realized I included the wrong link above - this is the link to the PrintActiveView sample.

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Print_active_vie...

Have a great rest of your day.

Reply
0 Kudos