Converting Excel charts to vector PDF

Hi,


We need to extract charts from Excel sheet and convert them to PDF format as a vector graphic.

We used Aspose.Cells (for .NET) to extract chart from Excel sheet and convert it to EMF. Then we used Aspose.PDF (for .NET) to convert it to PDF, but our chart became raster graphic.
Here is our code:

class Program {
static void Main(string[] args) {
var workbook = new Aspose.Cells.Workbook(“c:/temp/book2.xlsx”);
var chart = workbook.Worksheets[0].Charts[0];
chart.ToImage(“c:/temp/test.emf”, System.Drawing.Imaging.ImageFormat.Emf);

var pdf1 = new Aspose.Pdf.Generator.Pdf();
var sec = pdf1.Sections.Add();
var fs = System.IO.File.OpenRead(“c:/temp/test.emf”);

byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
var ms = new System.IO.MemoryStream(data);

var imageht = new Aspose.Pdf.Generator.Image(sec) {
ImageInfo = {
ImageFileType = Aspose.Pdf.Generator.ImageFileType.Emf,
ImageStream = ms
},
VectorGraphicsRenderingDPI = 140
};

sec.Paragraphs.Add(imageht);
pdf1.Save(“c:/temp/test.pdf”);
ms.Close();
}
}

Do you have any solutions for our problem?
We will also appreciate for some code example.

<o:p></o:p>


Hi Aleksander,



Well I am not sure if this is an issue with Aspose.Cells or Aspose.Pdf APIs. I have moved your thread into Aspose.Total forum where both Aspose.Pdf and Aspose.Cells teams could evaluate your issue properly.

Aspose.Cells does render vector graphics fine for the charts in the form of EMF file format that you specify in your code segment via Aspose.Cells APIs. If you still think it is an issue with Aspose.Cells component, please separate the issue with Aspose.Cells component only and provide your template file (containing the charts ), output Emf files, and some screen shots to reproduce the issue on our end, we will check it soon.

Thank you.

Hi Amjad,


Thank you for response. We think it is an issue with Aspose.Pdf component. I attached Book2.xlsx file and 2 screenshots. You can see that our vector emf looks great but pdf that was rendered by Aspose is raster graphic.

We are waiting for your prompt response and solution that will resolve our problem.


Hi,


Thanks for your evaluation.

As the issue is related to Aspose.Pdf component, one of the support staff member from Aspose.Pdf team will help you shortly here.

Thank you.

Hi,


Do you know any solution for our problem?
We are waiting for your response.


Hi Aleksander,

We are sorry for the inconvenience caused. While testing the scenario with the latest version of Aspose.Pdf for NET 9.2.0, We have managed to reproduce the reported issue and logged it in our bug tracking system as PDFNEWNET-36863 for further investigation and resolution. We will notify you via this thread as soon as it is resolved.

Please feel free to contact us for any further assistance.

Best Regards,