logo
small logo
  • Produits
  • Acheter
  • Assistance
  • About
  • Panneau du client Assistance
    • en
    • de
    • JP
    • ZH
  • Page d'accueil
  • /
  • Articles
  • /
  • How to print a picture from the report by clicking
  • Toilet paper printing

    30 mars 2020

    Gentlemen jokes aside! Today we are talking about toilet paper. This essential hygiene product was

    read more
  • How to print business cards from a Delphi application

    24 août 2020

    Applications built in Delphi are less common than, for example, those built in C #.

    read more
  • Working with NuGet packages in FastReport

    22 novembre 2021

    UPD: Applies to the versions of FastReport .NET before 2022.2. License packages are now available

    read more
  • How to use Online Designer in ASP .NET Core

    17 janvier 2018

    One of the novelties by FastReport .NET 2018 was the adaptation of OnlineDesigner to the

    read more
  • PreviewControl.OnPrint and PreviewControl.OnExport Events

    1 octobre 2020

    In FastReport 2019.4 added the ability to subscribe to PreviewControl.OnPrint and PreviewControl.OnExport events, which are

    read more

How to print a picture from the report by clicking

29 avril 2020

Many users of report generators fairly standard functionality in their everyday work. But sometimes they have to deal with non-trivial tasks, and then search for a solution may take a lot of time and effort. But perhaps the best solution is to ask the developers to get the most qualified assistance. This is done by one of the users of the generator Telerik Reporting reports. The problem was to print a picture of the object image in the report:

https://www.telerik.com/forums/print-a-picture-from-a-picturebox

The report may contain images not only uploaded during the design, but those that are stored binaryly in the database. Imagine a situation where you only need to print the right images from a report with many pages of data. At first glance, this is a big problem. You can export the report to HTML, copy the image you want to the graphics editor, and only then send it to print. And you can make an interactive report that will allow you to print pictures by clicking. Such solution is offered by Telerik specialists, in response to a user's question.

It's a great solution. Let's look at how to solve this problem in the FastReport.Net report. In fact, there is nothing simpler. All you need to do is create an event handler clicking on the picture object:

 

And add couple methods to the report script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//picture object
 public Image img;
 //printing method
 public void Print()
 {
 System.Drawing.Printing.PrintDocument picture = new System.Drawing.Printing.PrintDocument(); 
 picture.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(picture_PrintPage); 
 DialogResult result = new PrintDialog().ShowDialog();
 if (result == System.Windows.Forms.DialogResult.OK)
 {
 picture.Print();
 }
 }
 
 private void picture_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 { 
 e.Graphics.DrawImage(img, new Point(0, 0)); //picture and posirion on one page
 }
 
 private void Picture1_Click(object sender, EventArgs e)
 {
 img = (sender as PictureObject).Image; //We get the picture from the chosen object
 Print(); //execute printing
 }

  As you can see, just need to get a picture of the selected object and execute printing. In the method of printing, we have created the event handler print a document, which used the resulting image. Now, when viewing a report in the viewer, you can click on the picture and send it to print:

 

But if u do not need to print but only save on a local drive, so you can proceed in the similar way:

1
2
3
4
private void Picture1_Click(object sender, EventArgs e)
 {
 (sender as PictureObject).Image.Save("C:\\Temp\\image.bmp");
 }

 Thus, printing of the picture by ckick from the FastRepor.Netreport is very easy to perform.

A propos de notre produit Acheter
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport Interactivity Report Printing

Ajouter un commentaire
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Acheter
  • Télécharger
  • Documentation
  • Avis
  • Comment désinstaller nos produits
  • FAQ
  • Tutoriel vidéo
  • Forum
  • Support SLA
  • Articles
  • Nos actualités
  • Dossier Presse
  • Partenaires
  • Extended licensing
  • Nous contacter

© 1998-2023 by Fast Reports Inc.

  • Politique de confidentialité
  • Cookies Policy
  • Pas une offre publique

Trustpilot
By clicking “Accept all, you agree Fast Reports can store cookies on your device and disclose information in accordance with our Cookie Policy.