Page 1 of 2
How to print report in black and white?
Posted: Mon Sep 19, 2016 12:42 pm
by a.ebbini
Hello Support Team,
How to apply black and white on export or print only and showing it throw report viewer with colors?
Because the report after will be cached after preview, i try to apply black and white ExportReportResponse,PrintReport but it dosen't work.
Code: Select all
Private Sub RV_ExportReportResponse(sender As Object, e As StiExportReportResponseEventArgs) Handles RV.ExportReportResponse
If AdvancedOptions.IsPrintOptionSelected Then
MakeBlackAndWhite(e.Report)
End If
End Sub
Private Sub RV_PrintReport(sender As Object, e As StiPrintReportEventArgs) Handles RV.PrintReport
If AdvancedOptions.IsPrintOptionSelected Then
MakeBlackAndWhite(e.Report)
End If
End Sub
Public Shared Sub MakeBlackAndWhite(ByVal report As StiReport)
For Each page As StiPage In report.Pages
Dim comps As StiComponentsCollection = page.GetComponents()
For Each comp As StiComponent In comps
Select Case comp.GetType.Name
Case "StiText"
Dim TextComp As StiText
TextComp = report.GetComponentByName(comp.Name)
TextComp.Brush = New StiSolidBrush(Color.Transparent)
TextComp.TextBrush = New StiSolidBrush(Color.Black)
TextComp.Border.Color = Color.Black
TextComp.ComponentStyle = ""
End Select
Next
Next
End Sub
Re: How to print report in black and white?
Posted: Tue Sep 20, 2016 10:54 am
by HighAley
Hello.
Could you specify the version of our product and the name of the component that you use?
Thank you.
Re: How to print report in black and white?
Posted: Tue Sep 20, 2016 5:11 pm
by a.ebbini
Hello,
i'm using StiWebViewer component under Stimulsoft.Report.Web assembly with version 2016.1.28
i suggest when user submit a ticket in stimulsoft forum to fill compenent ,assembly, version and other fields that can help your support team to
serve the ticket and by this way you can help user to describe his\her issue and decrease the time form your side to serve the ticket.
for example usually i mention at least the version number in my ticket but sometimes i forget this thing like this ticket and by doing this i wast my and your time "it take two posts from you to ask the question and from me to answer it".
Please don't forget my main question
thank you.
Re: How to print report in black and white?
Posted: Wed Sep 21, 2016 9:31 am
by HighAley
Hello.
The rendered pages of the report are stored in the RenderedPages collection of the report.
If you want to change the color of the rendered components, you should do it with the components of the rendered pages.
Or if you change color of the components of the report template, please, render the report again.
As about adding information about the using product and its version. Some our customers use different products and can use different versions of our product simultaneously, so please specify necessary information in each your request.
Thank you.
Re: How to print report in black and white?
Posted: Wed Sep 21, 2016 9:34 am
by HighAley
Hello
Also you should use the ExportReport event instead of the ExportReportResponse event.
Thank you.
Re: How to print report in black and white?
Posted: Wed Sep 21, 2016 11:41 am
by a.ebbini
Hello,
What do you mean by this
If you want to change the color of the rendered components, you should do it with the components of the rendered pages.
i try to walk through
report.RenderedPages instead of
report.Pages,but still there is colors
Code: Select all
Public Shared Sub MakeBlackAndWhite(ByVal report As StiReport)
For Each page As StiPage In report.RenderedPages
Dim comps As StiComponentsCollection = page.GetComponents()
For Each comp As StiComponent In comps
Select Case comp.GetType.Name
Case "StiText"
Dim TextComp As StiText
TextComp = report.GetComponentByName(comp.Name)
TextComp.Brush = New StiSolidBrush(Color.Transparent)
TextComp.TextBrush = New StiSolidBrush(Color.Black)
TextComp.Border.Color = Color.Black
TextComp.ComponentStyle = ""
End Select
Next
Next
End Sub
Re: How to print report in black and white?
Posted: Thu Sep 22, 2016 10:27 am
by HighAley
Hello.
Could you send us a sample project that reproduces the issue?
We need to reproduce the issue on our side to help you.
Thank you.
Re: How to print report in black and white?
Posted: Mon Sep 26, 2016 9:07 am
by a.ebbini
Hello,
Sorry it is hard to send project but mainly i made report preparing in page_Load,but I made a step by adding code at ExportReport and PrintReport events
Code: Select all
Private Sub RV_ExportReport(sender As Object, e As Stimulsoft.Report.Web.StiExportReportEventArgs) Handles RV.ExportReport
Sky.Bayan.Business.Reports.Functions.MakeBlackAndWhite(e.Report)
e.Report.Compile()
e.Report.Render()
RV.Report = e.Report
End Sub
Private Sub RV_PrintReport(sender As Object, e As Stimulsoft.Report.Web.StiPrintReportEventArgs) Handles RV.PrintReport
Sky.Bayan.Business.Reports.Functions.MakeBlackAndWhite(e.Report)
e.Report.Compile()
e.Report.Render()
RV.Report = e.Report
End Sub
By doing this i achieve my objective,but also i have two problems
1)when i export report without colors then press on sort or collapse the report appears without colors
2)when press sort or collapse then i try to export the report an error appear Report already compiled "attached"
Please i need help
Re: How to print report in black and white?
Posted: Tue Sep 27, 2016 6:41 am
by HighAley
Hello.
I will try to explain the issue one more time.
Before the exporting or printing you have rendered report in Viewer.
Then the ExportReport or PrintReport event are fired you need to change the color of the components of the rendered report.
So you should NOT compile and render the report.
Now the main issue. You go through rendered components and look for the StiText. And you already have this component in
comp variable. So you should not call
Code: Select all
TextComp = report.GetComponentByName(comp.Name)
Especially because you get the component of the report template. Just remove this line and change the color of the
comp.
Thank you.
Re: How to print report in black and white?
Posted: Tue Sep 27, 2016 1:24 pm
by a.ebbini
Hello,
first i solve the first problem
1)when i export report without colors then press on sort or collapse the report appears without colors
By doing this
Code: Select all
Private Sub RV_ExportReport(sender As Object, e As Stimulsoft.Report.Web.StiExportReportEventArgs) Handles RV.ExportReport
If Session(PrintInColors) <> Session(PrintInColorsLastState) Then
Session(PrintInColorsLastState) = Session(PrintInColors)
ChangeEvenStyle(e.Report, Session(PrintInColors))
e.Report.Compile()
e.Report.Render()
If Not Session(PrintInColors) Then
MakeBlackAndWhite(e.Report)
End If
End If
End Sub
Private Sub RV_PrintReport(sender As Object, e As Stimulsoft.Report.Web.StiPrintReportEventArgs) Handles RV.PrintReport
If Session(PrintInColors) <> Session(PrintInColorsLastState) Then
Session(PrintInColorsLastState) = Session(PrintInColors)
ChangeEvenStyle(e.Report, Session(PrintInColors))
e.Report.Compile()
e.Report.Render()
If Not Session(PrintInColors) Then
MakeBlackAndWhite(e.Report)
End If
End If
End Sub
Public Shared Sub MakeBlackAndWhite(ByVal report As StiReport)
For Each page In report.RenderedPages
Dim comps As StiComponentsCollection = page.GetComponents()
For Each comp As StiComponent In comps
Select Case comp.GetType.Name
Case "StiText"
Dim TextComp As StiText = comp
TextComp.Brush = New StiSolidBrush(Color.Transparent)
TextComp.TextBrush = New StiSolidBrush(Color.Black)
TextComp.Border.Color = Color.Black
TextComp.ComponentStyle = ""
End Select
Next
Next
End Sub
Public Shared Sub ChangeEvenStyle(ByVal report As StiReport, ByVal Add As Boolean)
If Not report.Styles.Contains("EvenStyle") Then Exit Sub
Dim EvenStyle As String = Nothing
If Add Then
EvenStyle = "EvenStyle"
End If
For Each page In report.Pages
Dim comps As StiComponentsCollection = page.GetComponents()
For Each comp As StiComponent In comps
Select Case comp.GetType.Name
Case "StiDataBand"
Dim DataBandComp As StiDataBand = comp
DataBandComp.EvenStyle = EvenStyle
Case "StiHierarchicalBand"
Dim DataBandComp As StiHierarchicalBand = comp
DataBandComp.EvenStyle = EvenStyle
End Select
Next
Next
End Sub
But the second problem still yet
2)when press sort or collapse then i try to export the report an error appear Report already compiled "attached"
You advise me to should NOT compile and render the report at export and print events ,but i need to compile and render because some times there is components have style and as i tried change style property need compile and render as i mentioned MakeBlackAndWhite function that i attached in the first post
I need you advise.