Image in landscape

hello; for our financial reports I need our images which are charts produced from apose.chart to be inserted in landscape mode in the PDF. in other words the image to actually go length wise on the page.
I have tried using section.islandscape=true but this does not seem to help.

Thanks

Dear Bahman,

Thank you for considering Aspose.

Here is the code have tested for landscape:

Dim chart As chart = New Aspose.Chart.Chart()
chart.Height = 600 '(image is set too 800*600 in aspx designer)
chart.Width = 800

'Add a title
Dim title As Title = New Title()
title.Text = “TEST”
title.Font = New System.Drawing.Font(“Arial”, 14)
chart.Titles.Add(title)
'Set axis label formatting.
chart.ChartArea.AxisY.DefaultLabel.Format = “P2”
chart.ChartArea.AxisX.DefaultLabel.Format = “dd-MMM-yy”
'Add data
Dim series1 As ASeries = New ASeries()
series1.ChartType = ChartType.Bar
series1.DataPoints.Add(New DateTime(2003, 1, 31), -0.012)
series1.DataPoints.Add(New DateTime(2003, 2, 28), 0.0075)
series1.DataPoints.Add(New DateTime(2003, 3, 1), 0.01)
series1.DataPoints.Add(New DateTime(2003, 4, 30), 0.012)
series1.DataPoints.Add(New DateTime(2003, 5, 31), -0.045)
series1.DataPoints.Add(New DateTime(2003, 6, 30), -0.045)
series1.DataPoints.Add(New DateTime(2003, 7, 31), -0.012)
series1.DataPoints.Add(New DateTime(2003, 8, 31), 0.0075)
series1.DataPoints.Add(New DateTime(2003, 9, 30), 0.01)
series1.DataPoints.Add(New DateTime(2003, 10, 31), 0.012)
series1.DataPoints.Add(New DateTime(2003, 11, 30), -0.045)
series1.DataPoints.Add(New DateTime(2003, 12, 31), -0.045)

chart.NSeries.Add(series1)
'Just to make it visible more like the original.
chart.ChartArea.AxisX.IsMajorGridVisible = False
chart.ChartArea.AxisX.IsMajorTickMarkVisible = False
chart.ChartArea.LegendBox.IsVisible = False
'This seems like it has to be after NSeries.Add, otherwise does not work.
chart.ChartArea.IsXAxisCrossingZero = True

Dim tempPath As String = “E:/Temp”
Dim imageFile As String = chart.GetImageFile(tempPath, System.Drawing.Imaging.ImageFormat.Png)
chart.Save(imageFile, True)


’ Gets the image filename.
Dim pos As Integer = imageFile.LastIndexOf("")
Dim imageFilename As String = imageFile.Substring(pos)

’ Displays the chart in the myimage control.
'ImgHolder.ImageUrl = “Temp/” + imageFilename


'PDF convert. no matter it will not save b/c of size
Dim bmap As Bitmap = chart.Save()




’ Gets the image filename.
’ Displays the chart in the myimage control.

Dim mstream As New System.IO.MemoryStream()
'Begin Pdf Conversion

bmap.Save(mstream, System.Drawing.Imaging.ImageFormat.Bmp)
Dim myreader As New System.IO.BinaryReader(mstream)
Dim mypdf As New Pdf()
Dim sec1 As Section = mypdf.Sections.Add()

'sec1.PageInfo.PageWidth = chart.Width
'sec1.PageInfo.PageHeight = chart.Height
sec1.PageInfo.PageWidth = PageSize.A3Width
sec1.PageInfo.PageHeight = PageSize.A3Height

sec1.IsLandscape = True
sec1.PageInfo.Margin.Top = 0
sec1.PageInfo.Margin.Bottom = 0
sec1.PageInfo.Margin.Left = 0
sec1.PageInfo.Margin.Right = 0

Dim myimage As New Aspose.Pdf.Image(sec1)
myimage.ImageInfo.ImageFileType = ImageFileType.MemoryBmp
myimage.ImageInfo.OpenType = ImageOpenType.Memory
'myimage.ImageScale = 0.5F
'myimage.ImageInfo.FixWidth = 400
mstream.Position = 0

myimage.ImageInfo.MemoryData = myreader.ReadBytes(mstream.Length)
sec1.Paragraphs.Add(myimage)
bmap.Dispose()

mypdf.Save(“c:\Chart.pdf”)

Tommy, thank you for your time, this did not work however.
I want the actual image to be landscape in the pdf, in other words the image needs to be rotated left on the actual pdf

In a PDF there is a button that allows you to Rotate CounterClockWise, is there api for this?
does it make sense what I need ?

in summary I want to know if aspose.pdf has api calls to do this

1. Rotate CounterClockWise (equivalant to clicking on Rotate button in Acrobat Reader)
2. Have PAGE SETUP be landscape, it seems setting section to landscape is not what Im looking for, is there API that makes Page Setup landscape? (equivalant to going to page setup in Acrobat Reader, click on Landscape)

thanks for your time
bahman

Dear Bahman,

Thank you for considering Aspose.

I understand what you need. Rotating CounterClockWise is not supported in the current version. The landscape setting in Aspose.Pdf will only exchange the page width and height. There are too many urgent tasks so we can’t support this function recently. But you can use the Bitmap.RotateFlip method to rotate the image and then add it to pdf.


Thanks, I actually figured out rotateflip earlier today, and it works fine for our needs, thanks