Jump to content

itextsharp e microsoft chart


chromatinpt
 Share

Recommended Posts

Boas!

Tenho um chart num form e pretendia conseguir envia-lo para um pdf.

Encontrei esta solução para asp.net.

http://www.mikesdotnetting.com/Article/115/Microsoft-Chart-Controls-to-PDF-with-iTextSharp-and-ASP.NET-MVC

Contudo não consigo por a funcionar tentando adaptar a C# num form.

Tenho um chart1 com determinada série.

Não sei como ir buscar o chart1, converter para imagem e passá-lo ao document.Add(chartimage);

Alguma ideia?

Obrigado!

Link to comment
Share on other sites

Nesse artigo q mostraste a imagem é gerada dinamicamente.

Os passos q deves seguir são os seguintes:

Criar um memory stream com os bytes da imagem.

...

using (var chartimage = new MemoryStream())

  {

    chart.SaveImage(chartimage, ChartImageFormat.Png);

    return chartimage.GetBuffer();

  }

...

É aqui q isso é feito no artigo.

Depois precisas criar uma imagem com esse byte array, vê como ele faz este passo:

...

var image = Image.GetInstance(Chart());

...

E com isso tens tudo o q precisas.

Matraquilhos para Android.

Gratuito na Play Store.

https://play.google.com/store/apps/details?id=pt.bca.matraquilhos

Link to comment
Share on other sites

O itextsharp em C# custuma funcionar muita bem. Em VB também se vai utilizando, mas que eu saiba se em ASP é possivel em C# mais depressa é 😉

vê este exemplo http://www.codeproject.com/KB/cs/VisualReportingNET2003.aspx

"A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.