ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Print multiple images on a page
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

pssien

10 Posts

Posted - Apr 20 2015 :  03:02:43  Show Profile  Reply
I need to print a variable number of images on a page upon a user selection: 1, 2, 4 or 8 per page.
The user selects the images from a list, and then the dialog that asks for the number of images per page apears.
The images must be resized to fit in the destination rectangle and position in the page.
Is there an automatic way to do so with ImageEn, or what I need to do to resize and position each image in the page.

w2m

USA
1990 Posts

Posted - Apr 20 2015 :  09:06:03  Show Profile  Reply
You have at least 3 options to print multiple images on a page with ImageEn. You can use ImageEnMView1.MIO.DoPrintPreviewDialog, ImageEnMView1.MIO.PreviewPrintImages or the Windows Printing Wizard. The former allows you to specify the number of columns or rows and other parameters to get the thumbnails to appear as you specify:
procedure TForm1.Open1Click(Sender: TObject);
var
  i: integer;
  iFilename: string;
begin
  if OpenPictureDialog1.Execute then
  begin
    Screen.Cursor := crHourGlass;
    try
      for i := 0 to OpenPictureDialog1.Files.Count - 1 do
      begin
        iFilename := OpenPictureDialog1.Files[i];
        if FileExists(iFilename) then
        begin
          ImageEnMView1.AppendImage(iFilename);
        end;
      end;
    finally
      Screen.Cursor := crDefault;
    end;
  end;
  StatusBar1.Panels[2].Text := 'Pages: ' + IntToStr(ImageEnMView1.ImageCount);
end;


DoPrintPreviewDialog
procedure TForm1.Print1Click(Sender: TObject);
begin
  with ImageEnMView1.MIO.PrintPreviewParams do
  begin
    Printer.Orientation := poLandscape;
    PrintThumbnails := True;
    MarginTop := 0.5;
    MarginLeft := 0.5;
    MarginRight := 0.5;
    MarginBottom := 0.5;
    ThumbnailColumns := 2;
    ThumbnailRows := 2;
    ThumbnailSpacing := 0.5;
    ThumbnailStyle := ptFlat; { ptFlat, ptSoftShadow, ptBorder };
    ThumbnailShowText := False;
  end;
  ImageEnMView1.MIO.DoPrintPreviewDialog('Thumbnails', False, '', True); 
end;

Once the PrintPreviewDialog is visible you can change the printer orientation and the number of thumbnail columns or rows.



PreviewPrintImages
PreviewPrintImages allows you to create your own print preview dialog by displaying the preview in a TImageEnView and then control how the thumbnails are displayed by setting the PreviewPrintImages parameters with your own controls.

procedure TForm1.Print2Click(Sender: TObject);
begin
FormPrintPreview := TFormPrintPreview.Create(self);
  try
    iMaxBitmapWidth := FormPrintPreview.ImageEnView1.Width;
    iMaxBitmapHeight := FormPrintPreview.ImageEnView1.Height;
    iPrinter := Printer;
    iPrinter.Orientation := poLandscape;
    iColumns := 2;
    iRows := 2;
    iHorizSpace := 0.05;
    iVertSpace := 0.05;
    iPrintSelected := False;
    iMarginLeft := 0.05;
    iMarginTop := 0.05;
    iMarginRight := 0.05;
    iMarginBottom := 0.05;
    iDrawBox := False;
    iDrawText := False;
    iDrawShadow := False;
    iBoxColor := clBlack;
    iPageNo := 0;
    ImageEnMView1.MIO.PreviewPrintImages(FormPrintPreview.ImageEnView1.Bitmap,
      iMaxBitmapWidth, iMaxBitmapHeight, iPrinter, iColumns, iRows, iHorizSpace,
      iVertSpace, iPrintSelected, iMarginLeft, iMarginTop, iMarginRight,
      iMarginBottom, iDrawBox, iDrawText, iDrawShadow, iBoxColor, iPageNo);
    FormPrintPreview.ImageEnView1.Update;
    FormPrintPreview.ShowModal;
  finally
    FormPrintPreview.Free;
  end;




Windows Printing System
The Windows Printing System can also be used to print each image as a full page, two 4"x6" thumbnails, nine wallet sized thumbnails or a contact sheet with 35 thumbnails per page. You can not control exactly how many thumbnails are on a page or the exact dimensions of the thumbnails with the Windows Printing System. It is very professional looking and it does work well with ImageEn, however.
Uses System.Win.ComObj;
procedure TForm1.Print3Click(Sender: TObject);
{ Print image to Windows Printing Wizard. }
var
  i: integer;
  iFilename: string;
  iFiles: OleVariant;
  iCommDlg: OleVariant;
begin
  Screen.Cursor := crHourGlass;
  try
    iCommDlg := CreateOleObject('WIA.CommonDialog');
    iFiles := CreateOleObject('WIA.Vector');
    for i := 0 to ImageEnMView1.ImageCount - 1 do
    begin
        iFilename := ImageEnMView1.MIO.Params[i].FileName;
      iFiles.Add(iFilename);
    end;
    iCommDlg.ShowPhotoPrintingWizard(iFiles);
  finally
    Screen.Cursor := crDefault;
  end;
end;



Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

pssien

10 Posts

Posted - Apr 25 2015 :  10:09:55  Show Profile  Reply
Thanks Bill, this is what I was lookin for
Go to Top of Page

xequte

38616 Posts

Posted - Apr 30 2015 :  02:47:09  Show Profile  Reply
Thanks Bill,

I've added ShowWindowsPrintWizard(); as a helper function in iexWindowsFunctions.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: