YouTube | Facebook | X(Twitter) | RSS

PageLayoutControl の ActiveView 範囲を印刷

2016/9/1 (木)

private void print()
{
    //Form に配置した PageLayoutControl の ActiveView 範囲を印刷
 
    IActiveView pActiveView = axPageLayoutControl1.ActiveView;
    IOutputRasterSettings pOutputRasterSettings = (IOutputRasterSettings)pActiveeenDisplay.DisplayTransformation;
    pOutputRasterSettings.ResampleRatio = 1;     //ラスタのピクセル比率を1に変更
     
    IPrinter pPrinter = axPageLayoutControl1.Printer;
 
    pPrinter.Paper.PrinterName = "Adobe PDF";   //プリンタの変更(デバイスとプリ定)
     
    IEnvelope pPrinterBounds = new EnvelopeClass();
    IEnvelope pVisibleBounds =  new EnvelopeClass();
 
    axPageLayoutControl1.PageLayout.Page.GetDeviceBounds(pPrinter, 1, 0, pPrintetion, pPrinterBounds);  //出力ピクセル サイズの計算
    axPageLayoutControl1.PageLayout.Page.GetPageBounds(pPrinter, 1, 0, pVisibleB//出力用紙サイズの計算
 
    //出力ピクセルサイズの計算           
    tagRECT deviceRECT;
    deviceRECT.left = (int)pPrinterBounds.XMin;
    deviceRECT.top = (int)pPrinterBounds.YMin;
    deviceRECT.right = (int)pPrinterBounds.XMax;
    deviceRECT.bottom = (int)pPrinterBounds.YMax;
 
    //印刷
    int hDC  = pPrinter.StartPrinting(pPrinterBounds, 0);
    pActiveView.Output(hDC, pPrinter.Resolution, deviceRECT, pVisibleBounds, null);
    pPrinter.FinishPrinting();
 
    MessageBox.Show("Done");
}

関連記事

  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

-プログラミング, ArcGIS
-,

WINGFIELD since1981をもっと見る

今すぐ購読し、続きを読んで、すべてのアーカイブにアクセスしましょう。

続きを読む