Search code examples
c#pdf-generationitext

How can I override PDF print dialog settings with iTextSharp


Can any one tell me how to override page orientation selection in pdf print dialog using iTextSharp.

I am using these lines to override scaling and "Choose paper source by PDF page size"

writer.AddViewerPreference(PdfName.PRINTSCALING,PdfName.NONE);
writer.AddViewerPreference(PdfName.PICKTRAYBYPDFSIZE, PdfBoolean.PDFFALSE);

Solution

  • Please check table 150, entitled "Entries in a viewer preferences dictionary", in ISO-32000-1 (you can download a copy from the Adobe web site). It contains all the viewer preferences you can define in a PDF document, including PrintScaling and PickTrayByPDFSize, but you won't find any setting to override the page orientation selection.

    In other words: you're asking something that isn't defined in the PDF specification, and as a result, it isn't implemented in any PDF library (as far as I know).