0 Replies Latest reply: Oct 1, 2008 5:54 AM by 807589 RSS

    problem with landscape format on pdf file

    807589
      hello,

      i try to print an diagram in landscape format.
      if i use an pdf printer, the diagram is printed in landscape, but the pdf viewer shows me the file in portrait format.

      how can i rotate the pageformat?

      here´s my code for defining the page
      HashPrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
      attr.add(MediaSizeName.ISO_A4); 
      attr.add(OrientationRequested.LANDSCAPE); 
      //set the printable area within the paper total area : 
      MediaSize mediaSize = MediaSize.ISO.A4; 
      float mediaWidth = mediaSize.getX(Size2DSyntax.MM); 
      float mediaHeight = mediaSize.getY(Size2DSyntax.MM);   
      float printableX = 10; //mm 
      float printableY = 10; //mm 
      float printableWidth = (mediaWidth - (2 * printableX)); 
      float printableHeight = (mediaHeight - (2 * printableY)); 
      MediaPrintableArea printableArea = new MediaPrintableArea( printableX, printableY, printableWidth, printableHeight, Size2DSyntax.MM); 
      attr.add(printableArea); 
      and for printing
      PrinterJob pj = PrinterJob.getPrinterJob();
      if(pj.printDialog())
          {
              pj.setPrintable(this);
                  try
                  {
                      pj.print(attr);
                  }
                  catch (PrinterException ex)
                  {
                      Logger.getLogger(PanelLabelDiagramme.class.getName()).log(Level.SEVERE, null, ex);
                  }
          }