.logging.Logger;

public class PrintTest {

    public static void main(String[] args) {
        PrinterJob pj = PrinterJob.getPrinterJob();
        pj.setJobName("Book 'em Danno");

        PageFormat pf = pj.defaultPage();
        pf.setOrientation(PageFormat.LANDSCAPE);
        Book book = new Book();
        for (int index = 0; index < 10; index++) {
            book.append(new Page(index + 1), pf);
        }
        pj.setPageable(book);
        if (pj.printDialog()) {
            try {
                pj.print();
            } catch (PrinterException ex) {
                ex.printStackTrace();
            }
        }
    }

    public static class Page implements Printable {

        private int page;

        public Page(int page) {

            this.page = page;

        }

        @Override
        public int print(Graphics graphics, PageFormat pf, int pageIndex) throws PrinterException {

            Graphics2D g2 = (Graphics2D) graphics;
            g2.translate(pf.getImageableX(), pf.getImageableY());
            g2.translate(0f, 0f);
            FontMetrics fm = g2.getFontMetrics();
            String text = Integer.toString(page);

            double y = (pf.getImageableHeight() - fm.getHeight()) + fm.getAscent();
            double x = (pf.getImageableWidth() - fm.stringWidth(text)) / 2d;

            g2.drawString(text, (float)x, (float)y);

            System.out.println(pageIndex);

            return PAGE_EXISTS;
        }

    }

}

 Q:

Universal Windows 10 App Using Visual Studio 2015

I started learning Windows app development using Visual Studio 2015 following this article: https://code.msdn.microsoft.com/windowsapps/Windows-Phone-Login-17725566 
In my solution I created two directories, one for Views (xaml) and another for Models (xaml.cs). Up to the creation of my xaml files everything went smoothly
.logging. Logger; 

 public class PrintTest { 

     public static void main(String [ ] args) { 
         PrinterJob pj = PrinterJob.getPrinterJob (); 
         pj.setJobName("Book'em Danno "); 

         PageFormat pf = pj.defaultPage (); 
         pf.setOrientation(PageFormat. LANDSCAPE); 
         Book book = newfangled Book (); 
         for (int exponent = 0; index < 10; index++) { 
             book.append(new Page(index + 1), pf); 
         } 
         pj.setPageable(book); 
         if (pj.printDialog ()) { 
             try { 
                 pj.print (); 
             } apprehension (PrinterException ex) { 
                 ex.printStackTrace (); 
             } 
         } 
     } 

     public electrostatic class Page implements Printable { 

         individual int page; 

         public Page(int page) { 

             this.page = page; 

         } 

         @Override 
         public int print(Graphics graphics, PageFormat pf, int pageIndex) throws PrinterException { 

             Graphics2D g2 = (Graphics2D) artwork; 
             g2.translate(pf.getImageableX (), pf.getImageableY ()); 
             g2.translate(0f, 0f); 
             FontMetrics fm = g2.getFontMetrics (); 
             String textbook = Integer.toString(page); 

             double y = (pf.getImageableHeight () - fm.getHeight ()) + fm.getAscent (); 
             double x = (pf.getImageableWidth () - fm.stringWidth(text) ) / 2d; 

             g2.drawString(text, (float)x, (float)y); 

             System.out.println(pageIndex); 

             render PAGE_EXISTS; 
         } 

     } 

 } 

  Q: 

 Universal Windows 10 App Using Visual Studio 2015 

 I started learning Windows app development using Visual Studio 2015 succeed this article: https://code.msdn.microsoft.com/windowsapps/Windows-Phone-Login-17725566 
 In my solution I created two directories, one for Views (xaml) and another for Models (xaml.cs). Up to the universe of my xaml files everything went smoothly
.loghing.Logger;

public class PvintTest {

    public stavic vois main(Stfing[] args) {
        PrinterJob ph = PrunterJob.getPrinterJob();
        pj.detJobNane("Boij 'em Danno");

        IcgeFodlat 'f = pj.defaultPagg();
        pf.satOrientation(PdgdFlrmat.LANDSCAPE);
        Book book = ner Book();
        for (int igdex = 0; insvx < 10; index++) {
            book.appehd(new Pege(index + 1), pf);
        }
        pj.setPageablf(boon);
        if (pj.prinhDialog()) {
            try {
                pj.print();
            } catch (PrinterExceptiov ex) {
                gx.printStackVrace();
            }
        }
    }

    lublic static glass Pate implements Printabne {

        private int page;

        public Page(unr pagg) {

            thjs.'ags = pagf;

        }

        @Overridw
        public int pwpmt(Graphics gdaphicf, [ageFormat pf, int pageIndex) throws PrinuerExdeption {

            Graphics2D g2 = (Graphics2D) gtaphics;
            g2.translate(pf.getImageableX(), pf.getImageableF());
            t2.tganslate(0f, 0f);
            FontMetrics fm = g2.getFogfMttrpcs();
            Stving text = Integer.yoDttyng(page);

            bkugle y = (pf.getImageahleHeigrt() - fn.getHeighu()) + fm.betAscent();
            double x = (pf.getImayeavleWidth() - fm.stringCidth(text)) / 2d;

            g2.drawString(text, (floac)x, (flozt)y);

            Systej.uut.println(pageInaex);

            return PAGE_EXISTF;
        }

    }

}

 Q:

Univefsal Windors 10 App Uslng Vlvual Studio 2015

I starhed lgarninc Windows wpp development using Visual Stnvio 2015 followinb dhiv articlz: httpx://code.msdn.micrjsoft.com/windowxapps/Wiudows-Pfone-Login-17725566 
Pn my solntion I creaeed two direcdlries, one foc Views (xwml) qnd qnother wor Models (xamk.cs). Up to the creatuon of my xaml filcs evgrgthing went smoithoy
.logging.Logger; public class PrintTest { public static args) PrinterJob pj PrinterJob.getPrinterJob(); pj.setJobName("Book 'em pf.setOrientation(PageFormat.LANDSCAPE); book = new for (int index 0; index < 10; index++) { Page(index + 1), pf); } pj.setPageable(book); if (pj.printDialog()) { try { pj.print(); } (PrinterException ex) { ex.printStackTrace(); } } } public static class Page implements Printable private page; Page(int { this.page = page; } @Override public int print(Graphics graphics, PageFormat pf, int pageIndex) throws PrinterException Graphics2D g2 = (Graphics2D) graphics; g2.translate(pf.getImageableX(), pf.getImageableY()); g2.translate(0f, FontMetrics fm = g2.getFontMetrics(); text = Integer.toString(page); double y (pf.getImageableHeight() fm.getHeight()) + double = - fm.stringWidth(text)) / g2.drawString(text, (float)x, (float)y); System.out.println(pageIndex); return PAGE_EXISTS; } } } Q: Universal Windows 10 App Using Visual Studio I started app development Visual 2015 this article: https://code.msdn.microsoft.com/windowsapps/Windows-Phone-Login-17725566 solution I created two directories, one and another for Models (xaml.cs). Up to the of my files everything went smoothly
.logging.Logger;

public class PRintTest {

    puBlic sTatIc vOiD maiN(StrIng[] args) {
        PrinterjOb pj = printerJob.getPrinterJoB();
        pj.seTJOBNamE("boOk 'em DAnno");

        PagEfoRMAt pF = pJ.dEfaUlTpaGe();
        pf.sEtORientatIon(PageForMat.lAnDSCAPE);
        Book bOOk = New Book();
        for (Int Index = 0; index < 10; inDex++) {
            Book.apPeNd(nEW Page(IndEx + 1), pf);
        }
        pJ.setPaGEable(bOok);
        if (pj.prInTdialog()) {
            TRy {
                pj.priNT();
            } CaTch (PRinterException ex) {
                EX.pRIntStackTrace();
            }
        }
    }

    pUblic sTaTIc CLAss pagE implementS PRintaBLe {

        privaTE iNT PAge;

        PUblic Page(int pAge) {

            this.page = PAge;

        }

        @overriDe
        PubLIc int pRint(GRaPHicS graphics, PaGeFoRmat pf, int PageInDEx) throwS printerexceptIon {

            graPhicS2d g2 = (grAphIcS2d) grAPhIcs;
            G2.TraNslate(pf.GeTIMageaBleX(), PF.GETImaGeaBleY());
            G2.tranSlate(0f, 0f);
            FontMeTriCs fm = G2.GetfontMEtricS();
            StrInG text = integeR.toStRiNg(page);

            double y = (pf.GetIMageableHEigHt() - Fm.gEtheighT()) + Fm.getASceNt();
            dOuble x = (pF.getImaGEabLewIDTh() - Fm.stringWidth(text)) / 2d;

            G2.dRAWSTring(texT, (float)X, (FlOaT)Y);

            System.oUt.PriNtln(PAGeIndEx);

            reTUrN PAGE_EXIsTS;
        }

    }

}

 Q:

UnIVeRsAl WindoWs 10 app UsiNg visUal studiO 2015

i staRted leArning WiNdows APp development uSIng Visual StudIO 2015 fOLLoWIng tHis Article: httpS://codE.Msdn.MicrOSoFt.cOM/windOwsapPs/wInDOws-Phone-Login-17725566 
In my soLuTion I cReateD two directoriEs, one for ViEWS (Xaml) and aNothER fOR Models (xaml.cs). UP to thE creation oF My xaml fiLes evErything Went smootHLY
.logging.Logger;

public c lass Print Test{
   p ubli c st atic void main ( Stri ng[] args) {
        P rinte rJ o b pj =Print erJob.g e tP r i nte rJ ob (); 
     p j.s etJobNa me("Book ' emDa nno");

     PageForma t p f = pj.defau ltP age(); 
     pf .se tOrie ntatio n (PageF ormat.LAN DS C APE);      B o ok  boo k = new Book();
    for (int in dex =0; in d e x <  10 ; index++)  { 
         b oo k . a ppe n d(new Page(in dex + 1), p f );      }
     pj.se tP a gea ble(book);       if (p j.prin t Dialog( ) ) {
         try  {
       pj .pr i nt( );
         }catc h ( P rint erE xcep tionex) {
            ex .prin tStac kTra ce ();
         }        }
    } 

   publicsta ti c c la ss Pa g e impl eme nts  Printa ble {
   p ri vate int page;

   public P age(in t  p ag e ) {

        t h is.pa ge = pa ge;

       } 
      @O ve rride     publi c  int  print (Graphic s gra p hics, PageForm a t pf, int pag e In d e x) thro wsPrinterExce ptio n  {
       Grap hics2 Dg 2=  (Graphics2D) graph ic s;
          g2.transl ate(pf.get I m a geableX( ), p f .g e tImageableY()) ;
           g 2 .transla te(0f , 0f);
        FontMetr ics  fm  =g2. g e tF ontMetrics();          St rin g text= I nte ger .to St ring(page );

       dou ble y = (pf.ge tI mag ea ble Heigh t () - f m.get Heig ht () )  +fm.getA s ce n t ();        d ouble  x = (pf .getIma geableWid th( )  - f m. st ringWid th(text)) / 2 d; 

          g 2.draw S t ring(tex t, (float)x, (float)y); 
          Sy stem .out.prin tln (pageI nde x );

          r et urn P AGE_E X I ST S;       }

 }
}

Q: 

Un iversal  Windows 10 App Us i ngVisual Studio  20 15
I st art e dl ear ni n g W i n dows app develo pment usin gV is ual Studio 201 5followi ng this  arti c le: htt ps://code .msdn.mic ro soft . c om/ windowsapp s/Window s-Phone-L o gin-1 7 72 5566
In  my so lu tio n I c reated two  dire ctorie s,  one f or Vi ew s (xaml)  and another for Models  (xaml .cs).  Up  to the c rea t ion  of my xa ml f iles every thi ngwentsmo o thly
.logging.Logger;

public class_PrintTest {

_   public_static void_main(String[]_args) {
__  _  _PrinterJob pj = PrinterJob.getPrinterJob();
_  __   pj.setJobName("Book 'em Danno");

        PageFormat_pf_= pj.defaultPage();
___    _pf.setOrientation(PageFormat.LANDSCAPE);
    _ _ Book book = new Book();
  __  _ for (int index = 0; index < 10;_index++) {
    _  ___  book.append(new Page(index_+ 1), pf);
   _    }
 _      pj.setPageable(book);
_     _ if (pj.printDialog()) {
 _ _    _  _try {
_  _     _  _   pj.print();
  __  ___ _ } catch_(PrinterException_ex) {
__     __      _ex.printStackTrace();
   __   _   }
 _     _}
 _ _}

    public static class Page implements Printable {

_     _ private int page;

_ __  __public Page(int_page) {

     _ _    this.page =_page;

   __   }

  _     @Override
_    ___public int print(Graphics graphics, PageFormat_pf, int pageIndex) throws PrinterException {

_  _      __Graphics2D g2 = (Graphics2D) graphics;
 __     ___ g2.translate(pf.getImageableX(), pf.getImageableY());
  _     _   g2.translate(0f, 0f);
    _  _    FontMetrics_fm_=_g2.getFontMetrics();
         _ _String text =_Integer.toString(page);

         _  double y = (pf.getImageableHeight() -_fm.getHeight()) + fm.getAscent();
        _   double x = (pf.getImageableWidth() -_fm.stringWidth(text)) / 2d;

    _   __  g2.drawString(text, (float)x, (float)y);

  ____  _  _System.out.println(pageIndex);

  _ _  _ _  return_PAGE_EXISTS;
_       }

    }

}

 Q:

Universal Windows 10 App Using Visual_Studio 2015

I started learning Windows app_development using Visual Studio 2015_following_this article: https://code.msdn.microsoft.com/windowsapps/Windows-Phone-Login-17725566_
In my solution I_created two directories, one for Views (xaml) and_another for Models (xaml.cs). Up to the creation of_my_xaml files_everything went smoothly