Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.4, 5.0.0 alpha1, 5.0
    • Component/s: API, Viewer RI
    • Labels:
      None
    • Environment:
      ICEpdf

      Description


      Problem:
      If I print a document with the print button in the toolbar, the default setting for the printer page is "letter" (the first entry in the ComboBox.
      Is there a possibility to set the format "A4 (ISO/DIN ...) as the default format in the source code when I built the viewer panel?

      The following did not worked:

      The Viewer RI source code there is a class org.icepdf.ri.common.PrintHelper that does most of the lifting for printing. The constructor for this class let the user specify the paper size if needed. The Viewer RI by default set the default paper size to letter as you witnessed. If you want to set the default paper size to A4 there are couple ways to go.
      1. Get the source bundle of ICEpdf.
      2. Go to ./viewer/src/org/icepdf/ri/viewer/res/ICEpdfDefault.properties.
      3. There are comments in this file that give common dimensions in millimeters so the user can change the default paper size. Change those and re-build ICEpdf with Ant. (default target is build.all)

      The following change worked:

      from: MediaSizeName mediaSizeName = loadDefaultPrinterProperties();
      to: MediaSizeName mediaSizeName = MediaSizeName.ISO_A4;

      in the next methods of org.icepdf.ri.common.SwingConroller:

      public void showPrintSetupDialog()
      private void initialisePrinting(final boolean withDialog) { ...


      The customer suggested to implement a method in the SwingController such us
      setDefaultMediaSize(MediaSize mediaSize). Which will allow to perform this operation more easily without further code modifications

        Activity

        Hide
        Patrick Corless added a comment - - edited

        In order for the the ICEpdfDefault.properties to picked up the Viewer component needs to be setup with a properties manager. The setup is as follows.
        // create a new message bundle
        ResourceBundle messageBundle = ResourceBundle.getBundle(
        PropertiesManager.DEFAULT_MESSAGE_BUNDLE);
        Properties sysProps = System.getProperties();
        PropertiesManager propertiesManager = new PropertiesManager(sysProps, messageBundle);
        // create new controller and view builder
        SwingController controller = new SwingController();
        SwingViewBuilder factory = new SwingViewBuilder(controller, propertiesManager );
        // use the view builder to create a new viewer panel
        JPanel viewerPanel = factory.buildViewerPanel();
        /// When the application is closed makes sure to persist the settings.
        propertiesManager.saveAndEnd();
        // or just call save at any time to persist property changes.
        propertiesManager.saveProperties();

        Show
        Patrick Corless added a comment - - edited In order for the the ICEpdfDefault.properties to picked up the Viewer component needs to be setup with a properties manager. The setup is as follows. // create a new message bundle ResourceBundle messageBundle = ResourceBundle.getBundle( PropertiesManager.DEFAULT_MESSAGE_BUNDLE); Properties sysProps = System.getProperties(); PropertiesManager propertiesManager = new PropertiesManager(sysProps, messageBundle); // create new controller and view builder SwingController controller = new SwingController(); SwingViewBuilder factory = new SwingViewBuilder(controller, propertiesManager ); // use the view builder to create a new viewer panel JPanel viewerPanel = factory.buildViewerPanel(); /// When the application is closed makes sure to persist the settings. propertiesManager.saveAndEnd(); // or just call save at any time to persist property changes. propertiesManager.saveProperties();
        Hide
        Patrick Corless added a comment -

        Added a new method setPrintDefaultMediaSizeName(MediaSizeName mediaSize):void to the SwingController as a convenience method for setting the media size.

        Show
        Patrick Corless added a comment - Added a new method setPrintDefaultMediaSizeName(MediaSizeName mediaSize):void to the SwingController as a convenience method for setting the media size.

          People

          • Assignee:
            Patrick Corless
            Reporter:
            Evgheni Sadovoi
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: