Hi,
I’d like to create html Image maps and png files. However the HTML exporter can’t do this.
tag description:
HTML map tag
I found an old discussion on this topic:
Html image map
Here’s what i’d like to do:
1) We start with a Visio drawing
2) I’d like to create a png file of a specific size e.g. 800x600 or “800 and fit the rest”.
3) I’d like to mark specific shapes, e.g. by ID or by a list of shape references.
4) Aspose should also create a file. The marked shapes are clickable - or more abstract - the click events can be handeled in HTML.
I added a simple example for further discussion.
Please open the “SimpleShape.html” of the ZIP file.
I added some extra docs here.
Thank you!
Hi Harald,
Hi
thank you for your answer.
I wrote some sample code:
var diagram = new Diagram(@“C:\projects\AsposeTest\SimpleShapes.vsdx”);
var options = new ImageSaveOptions(SaveFileFormat.PNG);
var file = @“C:\projects\AsposeTest\SavePNG\test.png”;
diagram.Save(file, options);
The resulting image is 794x1123.
Two question:
1) Which mode do I have to use, to save only the area of visible shapes not the whole page? (Like the Viso exporter)
2) In the current example the blue rect dimension are 105,120 to 300, 235
So how do I get this coordinates in code?
Hi Harald,
ImageSaveOptions opts = new
ImageSaveOptions(SaveFileFormat.PNG);
opts.PageSize = new
PageSize(400f, 600f);
Haraldf:2) In the current example the blue rect dimension are 105,120 to 300, 235
Hi Imran,
I tried your code (using Aspose.Diagram.dll 4.3.0.0).
There are two issues:
class Program
{
static void Main(string[] args)
{
var diagram = new Diagram(@“C:\projects\AsposeTest\SimpleShapes.vsdx”);
var opts = new ImageSaveOptions(SaveFileFormat.PNG)
{
PageSize = new PageSize(400f, 600f)
};
// result is 533 x 800 - not 400x600 as expected
var file = @“C:\projects\AsposeTest\SavePNG\test.png”;
diagram.Save(file, opts);
var page = diagram.Pages[0];
for(var i = 0; i
{
var shape = page.Shapes[i];
var xform = shape.XForm;
var x = xform.PinX.Value;
var y = xform.PinY.Value;
var w = xform.Width.Value;
var h = xform.Height.Value;
Console.WriteLine(“Shape: " + i);
Console.WriteLine(string.Format(”{0}, {1}, {2}, {3}", x, y, w, h));
}
// Console output:
/*
Shape: 0
2,12598425196851, 9,84251968503937, 2,04724409448819, 1,18110236220473
Shape: 1
4,56692913385827, 9,25196850393701, 1,65354330708661, 1,5748031496063
*/
// expected results (messured with photoshop in the PNG):
// bounding box blue rect: 71, 87 - 133, 81
// bounding box red circle: 240, 114 - 108, 108
Process.Start(file);
}
Hi Harald,
Thank you for your inquiry. We managed to replicate the problem of page size adjustment. We have logged this issue under ticket id DIAGRAMNET-50212 in our issue tracking system. Your request has also been linked to this issue. We will keep you informed regarding any available updates.
Haraldf:
/*
Shape: 0
2,12598425196851, 9,84251968503937, 2,04724409448819, 1,18110236220473
Shape: 1
4,56692913385827, 9,25196850393701, 1,65354330708661, 1,5748031496063
*/
// expected results (messured with photoshop in the PNG):
// bounding box blue rect: 71, 87 - 133, 81
// bounding box red circle: 240, 114 - 108, 108
Please note that Aspose.Diagram API mimics the behavior of Microsoft Office Visio. The XForm properties return correct values as shown on the shape sheet (XForm_Prop.png). These values are in inches. We can easily convert inches to millimeter as follows:
[C#]
Diagram diagram = new Diagram(@"c:\temp\SimpleShapes.vsdx");
foreach (Shape shape in diagram.Pages[0].Shapes)
{
//FORMULA: Inches / .03937
var x = shape.XForm.PinX.Value / .03937;
var y = shape.XForm.PinY.Value / .03937;
var w = shape.XForm.Width.Value / .03937;
var h = shape.XForm.Height.Value / .03937;
//String.Format("{0:0.00}", 123.4567);
Console.WriteLine(string.Format("{0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}", x, y, w, h));
}
Result:
54.00, 250.00, 52.00, 30.00
116.00, 235.00, 42.00, 40.00
We hope, this helps.
Hi Imran,
I think I get it!
Thank you about the inch <-> cm transformation.
I still miss a factor. How can I convert from “cm” to Pixels in the PNG?
Is there a “dpi” faktor, that can be used?
Hi Harald,
Hi Imran,
sorry I don’t understand
The DIP factor must come from inside your renderer (or the Visio file or from Microsoft).
When saving the Visio File as PNG it’s rendered with a specific DPI size.
Edit:
I found out, that saving a 1x1 Inch square produces a 96x96 Pixel PNG.
Is this a Visio / Aspose.Diagram constant?
You can render a 10 Inch line as 1000 Pixels or as 2.
The code you gave me determines the DPI size of my current Windows screen.
How is this related to Aspose Diagram?
Hi Harald,
Haraldf:class Program{static void Main(string[] args){var diagram = new Diagram(@“C:\projects\AsposeTest\SimpleShapes.vsdx”);var opts = new ImageSaveOptions(SaveFileFormat.PNG){PageSize = new PageSize(400f, 600f)};// result is 533 x 800 - not 400x600 as expectedImran Rafique:We have logged this issue under ticket id DIAGRAMNET-50212 in our issue tracking system.
- “:” + image.VerticalResolution);
Hello Imran,
“inch value”*96/72 makes sense, as I came to the same result by a sample.
My question was on the exporter (about Setting/Getting) the DPI and not about the importer.
So - is the 96 a constant of the exporter
or is there some
ImageSaveOptions.DPI… constant/property?
Thank you.
(I am preparing a new full sample)
Hi, Harald
Hi Harald,
Hi Harald,
The issues you have found earlier (filed as DIAGRAMNET-50210) have been fixed in Aspose.Diagram for .NET 17.1.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.