Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
framacdev
Contributor III
Contributor III

Picture Box Rotation

Hi everyone,

I would like to know whether it is possible, when creating a picture box, to rotate it directly on Report Designer or I need to define it on the script? Do you know any workaround to do that?

Thank you

1 Solution

Accepted Solutions
Ruggero_Piccoli
Support
Support

Hi

There is not a control to rotate images. To achieve the required result:

  1. Change the scripting language of the document to Visual Basic
  2. Add the image in the template and keep it selected
  3. In the image propreties grid selec BeforePrint event in the script menu
  4. Create a new Visual Basic script and add the code

Private Sub xrPictureBox1_BeforePrint(sender As Object, e As System.Drawing.Printing.PrintEventArgs)
   Dim _pictureBox As XRPictureBox = TryCast(sender, XRPictureBox)
   Dim _image As Image = _pictureBox.Image
   Dim _bitmap As New Bitmap(_image)
   Dim _graphics As Graphics = Graphics.FromImage(_bitmap)
  _graphics.Clear(Color.White)
  _graphics.DrawImage(_image, 0, 0, _image.Width, _image.Height)
  _bitmap.RotateFlip(RotateFlipType.Rotate90FlipX)
  _pictureBox.Image = _bitmap
End Sub


For more details about PixelPerfect scripts refer to the video

Best Regards,

Ruggero

---------------------------------------------

When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads as HELPFUL if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads as HELPFUL if you feel additional info is useful to others.



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.

View solution in original post

7 Replies
Ruggero_Piccoli
Support
Support

Hi,

In what kind of report?

Best,

Ruggero



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
framacdev
Contributor III
Contributor III
Author

I encounter the mentioned issue in PixelReport

Ruggero_Piccoli
Support
Support

Hi

There is not a control to rotate images. To achieve the required result:

  1. Change the scripting language of the document to Visual Basic
  2. Add the image in the template and keep it selected
  3. In the image propreties grid selec BeforePrint event in the script menu
  4. Create a new Visual Basic script and add the code

Private Sub xrPictureBox1_BeforePrint(sender As Object, e As System.Drawing.Printing.PrintEventArgs)
   Dim _pictureBox As XRPictureBox = TryCast(sender, XRPictureBox)
   Dim _image As Image = _pictureBox.Image
   Dim _bitmap As New Bitmap(_image)
   Dim _graphics As Graphics = Graphics.FromImage(_bitmap)
  _graphics.Clear(Color.White)
  _graphics.DrawImage(_image, 0, 0, _image.Width, _image.Height)
  _bitmap.RotateFlip(RotateFlipType.Rotate90FlipX)
  _pictureBox.Image = _bitmap
End Sub


For more details about PixelPerfect scripts refer to the video

Best Regards,

Ruggero

---------------------------------------------

When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads as HELPFUL if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads as HELPFUL if you feel additional info is useful to others.



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
framacdev
Contributor III
Contributor III
Author

Thanks a lot for your quick response, Ruggero.

For static images your code works, but if I apply your code, doing data binding, to an object that contains a picture in Qlik Sense, it does not work.

Do I need to change something in the code that you have sent to me?

Thank you

Ruggero_Piccoli
Support
Support

I tested the code also with a Qlik Sense chart and it works. It is printed rotated in the generated PDF.

Could you share some screenshots of your template?

Maybe a Visual Basic developer can share some ideas.



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
framacdev
Contributor III
Contributor III
Author

I have noticed that the previous part of my PixelReport document was set with a level where one picture was stored. I wanted the same picture in another part of my report but rotated, so I have created another detail. What I needed to do was to Insert Detail Report in this section to print the rotated picture.

I did that and your code works great.

Thank you so much Ruggero

Ruggero_Piccoli
Support
Support

Molto bene!

Please remember to mak my answer as correct so it will be useful also for other people.

Buona giornata,

Ruggero



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.