Planner Printing Problems

Hi, 


The Planner printing functionality seems quite buggy.
I've tried various combinations of settings to no avail.
- FitToPage does not work very well. It chops off the side bar, header and footer.
- Trying to adjust the margins and sizes for these is not very helpful because these appear to be in device pixels so you just have to guess and don't know what device the report will be printed on. % based values would be more useful. Or do we just have to assume 600dpi and calculate it from that?
- The side bar doesn't print properly. It is supposed to start at 9am with 15 minute intervals 9:15, 9:30, 9:45. Instead I get "42DP" with intervals at 48, 63, 78 ??
- The footer progress bars don't print properly. I just get the value. Would be better to be able to suppress these altogether if they don't print properly.
- The footer overwrites the footer progress bars no matter what I set the FooterSize to
- Icons don't print with transparent backgrounds
- A monochrome option would be useful
- There doesn't appear to be any way to change which printer the report is sent to. It just goes to the Default Printer

Can you suggest the best way to do this?

I will send you the results via email.

Regards
Adam

For anybody else struggling with this, here are some workarounds:


To change the printer to <PRINTERINDEX>

   TPrinter       *printer;                        // Point to global printer object
   wchar_t        device[255];                     // Device name
wchar_t        driver[255];                     // Driver name
wchar_t        port[255];                       // Port name
   unsigned int   devMode;                         // DevMode structure handle

   printer = Printer();

   printer->PrinterIndex = <PRINTERINDEX>;
   printer->GetPrinter(device, driver, port, devMode);
   printer->SetPrinter(device, driver, port, 0);

To calculate correct margins in device pixels:

TPrinter *printer = Printer();

printer->Orientation = poLandscape;

int pageWidth = GetDeviceCaps(printer->Handle, HORZSIZE);
int pageHeight = GetDeviceCaps(printer->Handle, VERTSIZE);
int resolutionWidth = GetDeviceCaps(printer->Handle, HORZRES);
int resolutionHeight = GetDeviceCaps(printer->Handle, VERTRES);

// Set desired margins/sizes in mm
double leftMarginMM   = 5.0;
double topMarginMM    = 5.0;
double rightMarginMM  = 5.0;
double headerSizeMM   = 8.0;
double sidebarWidthMM = 12.0;
double footerSizeMM   = 10.0;

int leftMargin   = leftMarginMM / (double) pageWidth * (double) resolutionWidth;
int topMargin    = topMarginMM / (double) pageHeight * (double) resolutionHeight;
int rightMargin  = rightMarginMM / (double) pageWidth * (double) resolutionWidth;
int headerSize   = headerSizeMM / (double) pageHeight * (double) resolutionHeight;
int sidebarWidth = sidebarWidthMM / (double) pageWidth * (double) resolutionWidth;
int footerSize   = footerSizeMM / (double) pageHeight * (double) resolutionHeight;

Planner->PrintOptions->Header = "Header";
Planner->PrintOptions->HeaderSize = headerSize;
Planner->PrintOptions->LeftMargin = leftMargin;
Planner->PrintOptions->RightMargin = rightMargin;
Planner->PrintOptions->TopMargin = topMargin;
Planner->PrintOptions->Orientation = poLandscape;
Planner->PrintOptions->SidebarWidth = sidebarWidth;
Planner->PrintOptions->HeaderAlignment = taCenter;
Planner->PrintOptions->HeaderFont->Size = 12;
Planner->PrintOptions->HeaderFont->Style = TFontStyles() << fsBold;
Planner->PrintOptions->Footer = "Footer";
Planner->PrintOptions->FooterAlignment = taLeftJustify;
Planner->PrintOptions->FooterSize = footerSize;
Planner->PrintOptions->FooterFont->Style = TFontStyles() << fsBold;
DayPlanner->PrintOptions->FitToPage = TRUE;


To fix the footer overwrite issue:

Change this line in planner.pas

    DrawRect.Top := YSize + HeaderHeight + GroupHeight +
      FPrintOptions.FHeaderSize + FPrintOptions.TopMargin;

to

    DrawRect.Top := YSize + HeaderHeight + GroupHeight +
      FPrintOptions.FHeaderSize + FPrintOptions.TopMargin + FooterHeight;

  1. I could not see "chopping off" when setting Planner.PrintOptions.FitToPage = true
    2) I could not see incorrect values in the sidebar. Do you use the event OnPlannerGetSideBarLines and if so, can it be incorrect values come from an incorrect implementation in this event handler?
    3) Completion in footer is at this time indeed not printed as progressbar, just a number. We've added this on the list for improvement.
    4) How exactly do you insert icons? Via imagelist? Via HTML formatted text in items? Other way?
    5) Print indeed goes to default printer. If you want to send this hardcoded to another printer, it will have to be done at application level code. Mpst typical, PrinterSetupDialog is called before printing that allows the end user to select printer / orientation / ...
  1. I assumed FitToPage would handle the side bar, header and footer but you need to specify the size for these. See my code above from converting size in mm to size in device pixels. It would be useful if the component did these calculations for you.
    2. I'm not using the OnPlannerGetSideBarLines event. It prints OK on a laser printer. It may be an issue with the Adobe PDF driver.
    3. I worked out how to suppress this from print outs
    4. I am using an ImageList with transparent PNG. Not sure how difficult it is to print these with transparent background on a printer canvas.
    5. My app doesn't use PrinterSetupDialog but it allows you to select which printer different reports go to. See my code above for overriding the printer. It would be useful if the component could do this for you. e.g. a PrintOptions->PrinterIndex, set it to -1 for default printer otherwise it uses the index specified.

We've added an improvement to handle the imagelist image transparency for printing. This will be available from v3.3.1.1