ArcGIS 9.2 Build 1500

  • ArcObjects Windows Forms application running outside of ArcMap, similar to ArcEngine product.
  • Accessing mxd to print out page layout to A3 paper. Mxd is saved with same settings as printer, see below:
  • Original code was copied from PrintActive View sample on ESRI site. This sample does run in the ArcMap environment, but I don't think this should have a bearing on my problem.

enter image description here

Actual Problem

For some strange reason when my code prints out the map - it always prints to B5 which is obviously wrong as it should be A3. Printer complains that it doesn't have B5 - no map gets printed and misery ensues!
On further inspection of the code it seems that something strange is happening, the code below is a cut down version of the sample code just to show how you get the problem:

IPrinter docPrinter;
IPaper docPaper;

/* printdocument is from the .NET assembly system.drawing.printing */
System.Drawing.Printing.PrintDocument sysPrintDocumentDocument;

/* Now we need to get the default printer name.  Since this is a generic command,
 * we can't use the printername property of the document.  So instead, we use the 
 * System.Drawing.Printing objects to find the default printer.
docPrinter = new EmfPrinterClass();
sysPrintDocumentDocument = new System.Drawing.Printing.PrintDocument();
docPaper = new PaperClass();

/* testing to see if printer instantiated in sysPrintDocumentDocument is the  
 * default printer.  It SHOULD be, but this is just a reality check.
bool isDefault = sysPrintDocumentDocument.PrinterSettings.IsDefaultPrinter;

if (isDefault)
    //Set docPaper's printername to the printername of the default printer
    docPaper.PrinterName = sysPrintDocumentDocument.PrinterSettings.PrinterName;

    //Need to have the same paper form as the mxd
    docPaper.FormID = (short) mapDocument.PageLayout.Page.FormID;

/* Now assign docPrinter the paper and with it the printername.  This process is two steps
 * because you cannot change an IPrinter's printer except by passing it as a part of 
 * the IPaper.  That's why we setup docPrinter.Paper.PrinterName first.
docPrinter.Paper = docPaper;

when the code sets the docPaper.FormID (it's defaulted to 1 which is esrPageFormLetter) and overwrites this value with the value in the mxd (IMapDocument) mapDocument.PageLayout.Page.FormID - in this case its 13 (esrPageFormSameAsPrinter), that makes sense as we saved the mxd to "Use Printer Paper Settings" (see image above).

The 13 value that is passed seems to cause some conflict in translation to the IPaper object - because it was passed 13 it thinks that is B5 and not to try and infer out the printer settings which should be A3.

The best I can make out of this - is that it must have something to do with Windows paper size constants e.g. DMPAPER_B5 - 13 - B5 (JIS) 182 x 257 mm.

Does anyone have a clue how to get round this problem?

enter image description here

  • Did you try changing the printer's default settings in window's control panel?
    – relima
    Feb 15, 2011 at 18:35
  • is your windows locale set to EN_US? try EN_GB - though I would switch off Scale Map Elements and use PDF for Export - and drop the pdf directly on the HP5500.- Speed will be faster as ArcMap is slow rasterizing.
    – Mapperz
    Feb 15, 2011 at 18:47
  • @Mapperz - nice hints n tips there! It is indeed in EN_GB.
    – Vidar
    Feb 15, 2011 at 19:16
  • Hmmm still getting no where with this - even when I export as PDF - the scale is slightly out, where as an export manually in ArcMap produces a perfect scale map?!?!?
    – Vidar
    Feb 16, 2011 at 11:47
  • IPaper.FormID is not the same as IPage.FormID. ESRI's documentation states that IPaper.FormID uses the Win32 DMPAPER_xxx constants, as you mentioned, so A3 would be FormID = 8 May 12, 2011 at 16:44

3 Answers 3


I did eventually fix this by using a PrintLayout control - which although not elegant did seem to fix the printing problem. This fault has also been assigned a NIM code with ESRI (NIM065953) too. But I don't know whether they will actually fix it, I guess it's a low priority to them.


I fixed this problem by setting the dataframe extend to "FixedScale":

MapFrame mapFrame = ...

A few hours ago, I came in this page with the same problem about printer page.

And now, I guess I could summit a final answer.

As you might think about, you need to solve this problem with Windows paper size constants.

My solution is to create a function using "switch" to convert the property of esripageFormID into the proper papersize index found in the Microsoft link above.

And because of my printer driver, I can't make it print A0 size or Custom Size, so I just let it go, and noticing user that"You can't print this kind of paper correctly".

  • I'm not clear whether you still have this problem, in which case this should be deleted as an answer and researched/asked as a new question, or whether you had this problem and are presenting your solution as an answer which is fine. Either way would you be able to edit your "answer" here to make that clearer, please?
    – PolyGeo
    Jan 28, 2015 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.