VSS Files Converted to PDF Blank

Hi Per,


Thank you for the details.
spurgeon:
Also, only 20 icons are shown, whereas I believe there are 300 in the 3015.vss file.
In the code example, we are placing shapes in a single page. If there is no more space on the page to place a shape, then it stops placing any other shape. However, we can remove this check to render shapes in multiple pages. It is not an issue.

We have raised the priority of ticket ID DIAGRAMNET-51171 because it is about rendering the incomplete shapes in the PDF format. We shall let you know once a significant progress has been made in this regard.

Hi Per,


In reference to the ticket ID DIAGRAMNET-51172, please try the code below. I have attached an output image for your kind reference:

[.NET, C#]
<span style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// create a new drawing
<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>Diagram diagram = <span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>new<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”> Diagram();<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// add master from an existing stencil <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
diagram.AddMaster(@“C:\Diagram\3015.vss”, “100BaseT hub”);<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// get Visio page <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
Aspose.Diagram.Page srcPage = diagram.Pages[0];<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// remove background page <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
srcPage.BackPage = <span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>null<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// place a shape in the drawing <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>long<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”> shapeID = diagram.AddShape(0, 0, “100BaseT hub”, 0);<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
Aspose.Diagram.Shape shape = srcPage.Shapes.GetShape(shapeID);<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// resize shape <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
shape.SetWidth(2 * shape.XForm.Width.Value);<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
shape.SetHeight(2 * shape.XForm.Height.Value);<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// move shape to the origin corner <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>double<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”> shapeWidth = shape.XForm.Width.Value;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>double<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”> shapeHeight = shape.XForm.Height.Value;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
shape.MoveTo(shapeWidth * 0.5, shapeHeight * 0.5);<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>shape.Foreign.ImgWidth.Value = shapeWidth;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>
shape.Foreign.ImgHeight.Value = shapeHeight;<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// trim page size <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
srcPage.PageSheet.PageProps.PageWidth.Value = shapeWidth;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
srcPage.PageSheet.PageProps.PageHeight.Value = shapeHeight;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// specify saving options <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
ImageSaveOptions opts = <span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>new<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”> ImageSaveOptions(Aspose.Diagram.SaveFileFormat.PNG);
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// set page count to save <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
opts.PageCount = 1;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// set starting index of the page <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
opts.PageIndex = 0;<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// save it <span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
diagram.Save(@“C:\Diagram\Output.png”, opts);
<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>

Hi Per,


Thank you for being patient. In reference to the ticket ID DIAGRAMNET-51171, our product team has plans to resolve it in the next month. It depends upon if everything goes by plan. We shall let you know in this forum thread once it is resolved.

Thanks, the code for scaling the shapes and then saving to bitmaps seems to work (DIAGRAMNET-51172), and therefore DIAGRAMNET-51171 is a lower priority to me at this point than the other open tickets (51182, 51183, 51184, 51185, 51186). I show how I’m creating 96x96px thumbnails while maintaining the aspect ratio in the code below.

Some .vss and .vssx files render pretty well to thumbnails using the code, but some do not. Do you know why some thumbs don’t render well? Attached are a couple of .vssx files from the Visio 2016 stencils library, as well as some other .vss files where I’ve seen rendering issues.

public string GetSafeFilename(string filename)
{
return string.Join(" ", filename.Split(Path.GetInvalidFileNameChars()));
}

public int GenerateStencilsImages(String inputPath, String outputDir)
{
try
{
diagram = new Diagram(inputPath);
if (diagram == null)
{
return -1;
}
}
catch (Exception e)
{
return -1;
}

int i = 0;
foreach (Master master in diagram.Masters)
{
try
{
i++;
string tempfile = outputDir + “\” + GetSafeFilename(master.Name) + “.png”;
// create a new drawing
Diagram stencil = new Diagram();

// add master from an existing stencil
stencil.AddMaster(diagram, master.Name);

// get Visio page
Aspose.Diagram.Page srcPage = stencil.Pages[0];

// remove background page
srcPage.BackPage = null;

// place a shape in the drawing
long shapeID = stencil.AddShape(0, 0, master.Name, 0);
Aspose.Diagram.Shape shape = srcPage.Shapes.GetShape(shapeID);
double w = 0;
double h = 0;
FitToBox(shape.XForm.Width.Value, shape.XForm.Height.Value, 1, 1, ref w, ref h); // .5 seems to be 48px when exported, 1=96px

// resize shape
shape.SetWidth(w);
shape.SetHeight(h);

// move shape to the origin corner
double shapeWidth = shape.XForm.Width.Value;
double shapeHeight = shape.XForm.Height.Value;

shape.MoveTo(shapeWidth * 0.5, shapeHeight * 0.5);
shape.Foreign.ImgWidth.Value = shapeWidth;
shape.Foreign.ImgHeight.Value = shapeHeight;
// trim page size
srcPage.PageSheet.PageProps.PageWidth.Value = shapeWidth;
srcPage.PageSheet.PageProps.PageHeight.Value = shapeHeight;
// specify saving options
Aspose.Diagram.Saving.ImageSaveOptions opts = new Aspose.Diagram.Saving.ImageSaveOptions(SaveFileFormat.PNG);
// set page count to save
opts.PageCount = 1;
// set starting index of the page
opts.PageIndex = 0;
// save it
stencil.Save(tempfile, opts);
}
catch (Exception e)
{
[//sMessageBox.Show](https://smessagebox.show/)("Exception: " + e.Message);
continue;
}
}
return 1;
}

private void FitToBox(double width, double height, double maxWidth, double maxHeight, ref double outWidth, ref double outHeight)
{
double widthRatio, heightRatio, multiplier;
if(maxWidth == -1) {
widthRatio = 1;
} else {
widthRatio = (1.0 * maxWidth) / (1.0 * width);
}
if(maxHeight == -1) {
heightRatio = 1;
} else {
heightRatio = (1.0 * maxHeight) / (1.0 * height);
}
if(widthRatio < heightRatio) {
multiplier = widthRatio;
} else {
multiplier = heightRatio;
}
double newWidth = width;
double newHeight = height;
if(multiplier < 1) {
newWidth = multiplier * width;
newHeight = multiplier * height;
}
outWidth = newWidth;
outHeight = newHeight;
}

Hi Per,


Thank you for sending stencil files. We are testing all your stencil files and shall get back to you soon. Please spare us a little time.

Hi Per,

Thank you for being patient. We have logged tickets in our bug tracking system as below:

File Name: FPVALV_M.vssx
DIAGRAMNET-51208: Incomplete rendering of icons from a VSSX Stencil
DIAGRAMNET-51209: An error occurred on saving a drawing in PNG

File Name: Gridstore.vss
DIAGRAMNET-51210: An error occurred on saving a drawing in PNG
DIAGRAMNET-51211: Incomplete rendering of icons from a VSS Stencil

File Name: VEHICL_VISIO2013_M.vssx
DIAGRAMNET-51212: Incomplete rendering of icons from a VSSX Stencil

In reference to the Visio drawing "Generic-Title-Blocks.vss", Aspose.Diagram for .NET API supports 2003 or higher versions of Visio. Please save your file in 2003 or higher VSS format, and then you will be able to import your stencil into Aspose.Diagram API.

Hi Per,


Thank you for being patient. We have a good news for you that the ticket ID DIAGRAMNET-51210 has been resolved. If there is no issue in the quality assurance phase, then this fix will be included in the next version 17.4.0 of Aspose.Diagram for .NET API. We shall inform you via this forum thread as soon as the new release is published.

Thanks for fixing that issue. Of the remaining issues, below is my prioritized list in order of priority. All except 51160 are important to me. The top group is something I need for a customer as soon as possible. I know there’s a lot here, but do you have an idea of which of these, if any, I might expect fixed in 17.4.0?


DIAGRAMNET-51182: Missing shapes on converting a VSD to PDF
DIAGRAMNET-51183: Displaced shapes on converting a VSD to PDF
DIAGRAMNET-51185: Displaced shapes on converting a VSD to PDF
DIAGRAMNET-51186: Incorrect layout of the meta type shapes on converting a VSD to PDF

DIAGRAMNET-51171: Incorrect rendering of VSD to PDF (stencils output)
DIAGRAMNET-51184: Incomplete boundary of the meta type shapes on converting a VSD to PDF

DIAGRAMNET-51208: Incomplete rendering of icons from a VSSX Stencil
DIAGRAMNET-51209: An error occurred on saving a drawing in PNG
DIAGRAMNET-51211: Incomplete rendering of icons from a VSS Stencil
DIAGRAMNET-51212: Incomplete rendering of icons from a VSSX Stencil

DIAGRAMNET-51160: Icons with wrong color on PNG export

Hi Per,


Thank you for the inquiry. All the listed ticket IDs have just been identified. Our product team is analyzing the root cause of each problem. The preparation of next version 17.4.0 is also in-progress which is expected to be released in the next couple of weeks. It is difficult for us to incorporate any other fix in the upcoming release. However, we are in communication with our product team. We shall let you know if they can include any other fix.

Hi Per,


Thank you for being patient. We have resolved the ticket ID DIAGRAMNET-51209, after the quality assurance phase, it will be included in the next version 17.4.0 of Aspose.Diagram for .NET API. Our product team has plans to include the fixes of ticket IDs DIAGRAMNET-51182 and DIAGRAMNET-51184 in the next version 17.4.0, however, these two tickets are not resolved yet. We shall let you know once a significant progress has been made in this regard.

The issues you have found earlier (filed as DIAGRAMNET-51209;DIAGRAMNET-51210) have been fixed in Aspose.Diagram for .NET 17.4.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as DIAGRAMNET-51172) have been fixed in Aspose.Diagram for .NET 19.7.

The issues you have found earlier (filed as DIAGRAMNET-51171) have been fixed in this update. This message was posted using Bugs notification tool by philip.zhou