中の技術日誌ブログ

C#とC++/CLIと
VBと.NETとWindowsで戯れる
 

目次

Blog 利用状況

ニュース

自己紹介

東京でソフトウェアエンジニアをやっています。
お仕事大募集中です。
記事執筆や、講師依頼とかでも何でもどうぞ(*^_^*)
似顔絵 MSMVPロゴ
MSMVP Visual C# Since 2004/04-2013/03

記事カテゴリ

書庫

日記カテゴリ

00-整理

01-MSMVP

印刷開始位置はプリンタへの印刷とプレビューで異なる

"印刷開始位置はプリンタへの印刷とプレビューで異なる"とだけ書いても何かわからないかもしれないのですが、どういうことかというと。

印刷関係にはSystem.Drawing.Printing.PrinterSettingsとか、System.Drawing.Printing.PrintDocumentあたりを使う。

PrintDocumentはどのように描画をするかを制御するクラスで、これのデリゲートのQueryPageSettingsとPrintPgaeにメソッドを登録して実際の描画ロジックを作成する。

印刷だけでなくプレビューも簡単に使えるようになっている。それがSystem.Windows.Forms.PrintPreviewControl, System.Windows.Forms.PrintPreviewDialogだ。

これらのコントロールなどにPrintDocumentを引き渡すと同じロジックが動くので、何も考えなくても画面に表示してくれることになっている。

だけど実際には違う。

何が違うのかというと余白の制御がまったく違う。

Preview系は0, 0の位置から描画できてしまうが、実際のプリンタで0, 0の位置から印字できるものはない。(と思う)

ちなみにうちのプリンタでは0.2inchずつ印字できない。

でも印字では0, 0の位置から印字するとちょうど0.2inch, 0.2inch離れたところから印字される。

結局プレビューでも自前で0.2inch, 0.2inch離れているかのような描画をしなければまったく同じイメージにならないということだ。

"プレビューで確認できているんですが"という投稿をたまに見るが、プレビュー=実際の印字イメージではない以上そこは自分で責任を持ってやってくださいということです。

まぁそうなると精密は余白サイズを取らないと絶対にうまくいかないので、

Wankuma.Interop.GetDeviceCapsWrapperクラス Version1
http://blogs.users.gr.jp/naka/articles/4400.aspx

なんかを利用してください。ということです。

#クラスの解説ちゃんと書かないとねぇ。

投稿日時 : 2004年9月20日 23:26

コメントを追加

# Today, I went to the beach with my kids. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She placed the shell to her ear and screamed. There was a hermit crab inside and 2024/08/01 7:01 Today, I went to the beach with my kids. I found a

Today, I went to the beach with my kids. I found a sea shell and gave it to my 4 year
old daughter and said "You can hear the ocean if you put this to your ear." She placed the
shell to her ear and screamed. There was a hermit crab
inside and it pinched her ear. She never wants to go back!
LoL I know this is totally off topic but I had to tell someone!

# Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something. I think that you could do with some pics to drive the message home a little bit, but other than that, this is excellent blog. An excellent read. 2024/08/01 10:03 Its like you read my mind! You appear to know a lo

Its like you read my mind! You appear to know a lot about this, like you wrote the book
in it or something. I think that you could do with some pics to drive the message home a little bit, but other than that, this
is excellent blog. An excellent read. I'll definitely be back.

# Oh my goodness! Impressive article dude! Thanks, However I am having problems with your RSS. I don't know the reason why I am unable to subscribe to it. Is there anyone else having similar RSS problems? Anyone who knows the solution can you kindly respo 2024/08/01 10:40 Oh my goodness! Impressive article dude! Thanks, H

Oh my goodness! Impressive article dude! Thanks, However I am having
problems with your RSS. I don't know the reason why I am unable to subscribe to it.
Is there anyone else having similar RSS problems?
Anyone who knows the solution can you kindly respond?
Thanx!!

# Tremendous things here. I am very satisfied to look your article. Thanks so much and I am having a look forward to touch you. Will you please drop me a e-mail? 2024/08/02 7:36 Tremendous things here. I am very satisfied to lo

Tremendous things here. I am very satisfied to look your article.
Thanks so much and I am having a look forward to touch you.
Will you please drop me a e-mail?

タイトル
名前
URL
コメント