title: Java SWT Print How to Print to File on Linux?
body: <p>I am trying to print a simple report using the code below. On Windows, this code works fine when attempting to print to PDF generator driver (instead of a real printer). But, on my Linux box, when I test the code below, the Linux print dialog opens but I do not seem to be able to capture the print to file filename. The problem that this creates is the report is printed using print-to-file to the current executing directory rather than to the location specified in the Print Dialog. (I want to user to be able to print-to-file and specify the location.)</p>
  
  <p>NOTE: This code uses some test print statements to determine the PrintDialog file path information--that is, I realize that I do not use this information.</p>
  
  <p><strong>Code Snippet</strong></p>
  
  <pre><code>        PrintDialog printdialog = new PrintDialog(Display.getDefault().getActiveShell(), SWT.NONE);
          PrinterData printerdata = printdialog.open ();
          if (printerdata.printToFile) {
              System.out.println("TESTING 2013-10-09:: " + printerdata.fileName) ;
  
          }
  
          if (printerdata != null) {
  
              ReportHeader header = new ReportHeader("Preprocessing Errors Report", true) ;  
              ReportFooter footer = new ReportFooter() ;
  
              // Create styled text for the report text itself
              StyledTextPrint reporttext = new StyledTextPrint() ;
              TextStyle reporttextstyle = new TextStyle().fontHeight(ReportDefaults.REPORTFONTSIZE) ;
              reporttext.append("Preprocessing Errors Report\n\n" + 
                      "Matter Name: " + systemprefs.getMatterName(systemprefs.getCurrentMatter()) +
                      "\n[" + systemprefs.getCurrentMatter() + "]\n\n" +              
                      TextLineSplitter.splitline(printablereporttext.toString(), 55).toString(), reporttextstyle) ;
  
              // Use page print to print all the formatted text
              PagePrint text = new PagePrint(
                      header, 
                      ReportDefaults.HEADERBOTTOMMARGIN, 
                      reporttext, 
                      ReportDefaults.FOOTERBOTTOMMARGIN, 
                      footer);
  
              ScalePrint stext = new ScalePrint(text) ;
  
              // Perform actual printing
              String reportfilename = "PreprocessingErrorsReport" + systemprefs.getCurrentMatter() ;
              PaperClips.print(new PrintJob(reportfilename, stext), printerdata) ;
  </code></pre>
  
  <p><strong>Other Info:</strong></p>
  
  <ul>
  <li>Uses Java SWT Paperclips for simple printing.
  <a href="https://code.google.com/p/swt-paperclips/" rel="nofollow">https://code.google.com/p/swt-paperclips/</a></li>
  <li>Java 7 </li>
  <li>List item</li>
  </ul>
  
  <p>Linux Ubuntu 13.04</p>