ICEpdf
  1. ICEpdf
  2. PDF-132

bug in PrintServices example using printHelper

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.2
    • Fix Version/s: 4.0
    • Component/s: Documentation
    • Labels:
      None
    • Environment:
      LINUX: 2.6.31-15-generic #50-Ubuntu SMP Tue Nov 10 14:54:29 UTC 2009 i686 GNU/Linux
      Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
    • Workaround Exists:
      Yes
    • Workaround Description:
      Hide
      modfiy a version of PrintHelper class constuctor so that the values of selectedService, printRequestAttributeSet, docAttributeSet can be passed from PrintServices.

      e.g. AKCPrintHelper printHelper = new AKCPrintHelper(vc, document.getPageTree(), selectedService, printRequestAttributeSet, docAttributeSet);
      Show
      modfiy a version of PrintHelper class constuctor so that the values of selectedService, printRequestAttributeSet, docAttributeSet can be passed from PrintServices. e.g. AKCPrintHelper printHelper = new AKCPrintHelper(vc, document.getPageTree(), selectedService, printRequestAttributeSet, docAttributeSet);

      Description

      The PrintServices example printed my pdf fine, however being in UK, the Letter size paper meant that the printout was not correctly aligned on my printer.

      I then modified printServices example to set the paper size to A4 and the orientation to LANDSCAPE.

                  printRequestAttributeSet.add(OrientationRequested.LANDSCAPE);
                  docAttributeSet.add(OrientationRequested.LANDSCAPE);

                  printRequestAttributeSet.add(MediaSizeName.ISO_A4);
                  docAttributeSet.add(MediaSizeName.ISO_A4);


      However despite modifying the settings of printRequestAttributeSet, docAttributeSet they never made any difference to the printer output.

      Having looked at the source of PrinterHelper (with my very limited Java skills) it seems that private class variables of the same name are created in PrinterHelper and the values from PrintServices are never passed into PrinterHelper.

      I also notice that there are 2 different variables in PrinterHelper called printServices. It is defined as a private class variable and also as a local variable inside the printHelper constructor.

      I am unsure whether this is intentional design however in order to get pdfs to print correctly on A4 paper I passed the values of printRequestAttributeSet, docAttributeSet from printServices into the printHelper constructor. This then ensured my settings were correctly set.

      I am not sure if it was necessary, but I also passed the value of selectedService from printServices as follows:

      AKCPrintHelper printHelper = new AKCPrintHelper(vc, document.getPageTree(), selectedService, printRequestAttributeSet, docAttributeSet);

      I hope this is sufficient information for you to look at this issue Patrick.

      Regards

      Alec

        Activity

        Hide
        Patrick Corless added a comment -

        I took a quick look at this and the Print services example is a little off. As you suggested a bunch of properties are set but never passed into the print helper. I'll make sure this get fixed for the release.

        Looks like you have already found a work around modding the PrintHelper example. Most of our European companies go into the PrintHelper source and change the default paper size on line 119-120. When I revisit this issue I'll see if I can make the print helper a little more customizable without having to modify the source.

        Show
        Patrick Corless added a comment - I took a quick look at this and the Print services example is a little off. As you suggested a bunch of properties are set but never passed into the print helper. I'll make sure this get fixed for the release. Looks like you have already found a work around modding the PrintHelper example. Most of our European companies go into the PrintHelper source and change the default paper size on line 119-120. When I revisit this issue I'll see if I can make the print helper a little more customizable without having to modify the source.
        Hide
        Patrick Corless added a comment -

        Updated PrintHelp and demo to make this process a lot easier for 4.0. Docs can be found here. http://wiki.icefaces.org/display/PDF/Print+Services+Example

        Show
        Patrick Corless added a comment - Updated PrintHelp and demo to make this process a lot easier for 4.0. Docs can be found here. http://wiki.icefaces.org/display/PDF/Print+Services+Example

          People

          • Assignee:
            Patrick Corless
            Reporter:
            Alec Cormack
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: