Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
977 views
in Technique[技术] by (71.8m points)

c# - Printing PDFs with changed default printer settings

Google/Bing didnt bring up any solution to my following problem, hope someone can help me:

We have to print various PDF files in our C# based program. Before we can print, we have to configure the printer, e.g. setting the orientation to landscape.

I tried to change the default printer settings e.g. like this:

PrinterSettings settings = new PrinterSettings();
settings.PrinterName = "\\SomeNetworkPrinter";
settings.DefaultPageSettings.Landscape = true;
settings.Duplex = Duplex.Horizontal;

We send the PDF to the printer via PDFSharp, which basically works, but my settings are completly ignored. Isn't it possible to change the default printer settings this way? Do we have any chance to change the settings and print our PDF-files?

Thank you very much in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

No, I don't think that's going to work.

You're creating a local PrinterSettings object which can be used to configure a PrintDocument which in turn can be sent to the printer using PrintDocument.Print().

If you're calling out to PDFSharp to orchestrate the printing, it's going to use whatever printer settings it defaults to, unless you're somehow passing your PrinterSettings to PDFSharp via the API?

If you can post the code you use to invoke PDFSharp, it would be of help in figuring out how to do this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...