I read this interesting article by Microsoft. I learned that a Visio file is nothing more than a Zip file containing XML with all the information about the graph.
Playing around with the code from the same article I managed to explore a Visio file, getting XML nodes for the shapes I'm interested in, for example.
My purpose is to draw the graph itself! But my primary constraint is that the application must not rely on Visio installed in the client. So I should write pure C# to render the graph, or reference some DLLs that help me to draw the graph without having Visio installed.
On the same article, at the bottom of the page, there is a link to something called pkgVisio. A VB project that can explore and display the graph. The problem with that project is 1) It's in VB! 2) It references several DLLs that I don't know and that I don't know where to get from (AxMicrosoft.Office.Interop.VisOcx, Microsoft.Office.Interop.Visio, Microsoft.Office.Interop.VisOcx, Microsoft.Practices.EnterpriseLibrary.Common, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging)
I am looking for a way to develop a program that can render a Visio file, or, if exists, a simple project that does the same thing.
Any hint or help will be really appreciated,
thank you
I think if you have a real-world diagram, this task is more or less hopeless. Although Visio vsdx file is composed of XML files which are plain text, inside those XML files there are formulas. The problem is not reading XML file, the problem is building a rendering engine, which is in fact a "giant calculator", as has been noticed once by one of Visio creators. Means, as a rule, you won't actually find the coordinates of shapes to render inside those XML files, but rather the rules to calculate those coordinates.
So my recommendation would be: forget it or use the commercial package if you want to render Visio diagrams without Visio
The mentioned libraries are:
VisOcx - this is Visio drawing control, it is only installed together with Visio itself. Basically this is ActiveX wrapper control for embedding Visio into your application.
EnterpriseLibrary - This is the Microsoft Enterprise Library
Related
I use Open XML SDK tool to parse pptx-files. Now I am going to develop my own .NET library/tool to generate an image from a PowerPoint slide. Open XML SDK in principle is not for such tasks, and I do not know where to start research?.
maybe to solve it better to use another programming language, for example, C++ (I also know it) with some library?
or it may be necessary intermediate convert pptx into some another format, for example, HTML and only then to image?
I also tried to investigate Aspose.Slides and Spire.Presentation libraries' dependencies in NuGet to know what they use to an image generation, but these attempts did not succeed.
This looks like a good starting point: Presentation to image conversion
The cited versions are old, but the syntax is still the same: PPT slides to images
My mistake, I misunderstood the end goal.
I need to deploy a visio visualization programmatically. For the moment I just need to add sticky notes with the attributes: size, position, color, text on it and text alignment, but the solution should be expandable with further shapes in the future. The information about the shapes is stored in google cloud firestore database. I am quite open for any kind of solutions and code language, but if possible it would be great to run google cloud functions, which supports Node.js, Python, and Go, but I also read about supporting .NET, moreover it should be open source if possible.
I am totally not an experienced code developer, thus it would be great if you could provide some code examples. That's what I actually miss in all the documentation I found.
As far as I researched the Visio 2016 SDK would be interesting in this case. But I didn't find close examples as I need. F.e. this link shows how to replace text in a shape, or this link shows how to add a rectangular shape. But the explanation is rare...
I analyzed the visio file itself with master..XML, page..XML etc., but the amount of values is confusing. And this leads me to the question how the SDK will handle this? How can I define master shapes, how do I format them?
Another option would be the Apose.Diagram API, but I am not shure if the sticky note is supported. An example is provided here. Unfortunately it's commercial, but if there is no other option i would go for it.
Thanks for advice!
just as an information about the actual state: i kind of "solved it" with manually manipulating the vsdx. the vsdx is just a compressed zip-file with ending .vsdx. If you rename it to .zip, you will see many xml-files. the file page1.xml is the one important if you just need to place simple shapes without relations to each other.
In the page1.xml there are xml-parts named as , just manipulate & multiplicate these parts.
I didnt try the sdk yet, or an third-party solution like apose.diagram, but for the actual use case of visualizing objects in form of a rectangle its good enough
I am searching from last two days but did not find any thing.
My requirement is to create a document viewer in my web application (C#.Net) and I don't want to use any third party tool for this. Can I convert the files in image or PDF or in any common formate which can be easly render on web page. I also can not use Introp object.
Any help will be highly appreciated
You mention in one of your comments that you'd like to write all the code yourself but don't know where to start. Here's how I would go about it...
First, you'll need to familiarize yourself with the Microsoft Office Format specification. You can find that here (there's a link to the technical specification). Office documents are actually a .zip file with an XML file inside along with any binary data representing attachments. Just renamed a .docx file as .zip and you'll be able to open it up and see the XML and any other supporting documents inside (same is true for xlsx, etc...).
Then you'll need to become intimately familiar with either PDF or HTML, as your job now will be to convert the various Office document structure into PDF or HTML structure, being sure to respect page layout, margins, order, etc...
As others have said, this is a large task which is why third party tools exist today. Also, each third party toolset has it's limitation as this is really hard to "get right" in all situations and there will be edge cases that work for one document and not another (because maybe they didn't use Microsoft Word to save the .docx, maybe they used OpenOffice and OpenOffice interpreted the standard slightly differently...)
If you cannot use COM/Interop technologies in your solution, you can take a look at the specialized 3rd party options. I see that you prefer not to use them, however, there are no existing built-in solutions in the .NET Framework. Check out my answer in a similar thread that describes how to accomplish exactly the same task using 3rd party libraries (for example, DevExpress, since I have experience with it). In addition, take a look at the Documents demo, where you can see how to create images/thumbnails from different types of MS Office documents.
I believe what you need is an intermediate representation of the documents which can be converted into an image for the viewer to display.
Lets me try to explain with the below diagram:
You can use tools like smallpdf or OfficeToPDF to do that. Just integrate them into your application.
Small PDF(https://smallpdf.com/library-detail)
officetopdf (https://officetopdf.codeplex.com/)
Is there a way to programmatically create PowerPoint presentations? If possible, I'd like to use C# and create PowerPoint 2003 presentations.
Yes, you can.
You will want to look into MSDN which has a pretty good introduction to it.
I might give you a word of warning, Microsoft Office interop is compatible with an API which is now more than 10 years old. Because of this, it is downright nasty to use sometimes. If you have the money to invest in a good book or two, I think it would be money well spent.
Here's a starting point for you. Use the search feature on MSDN MSDN Webpage. It's good for any Microsoft C# .NET style stuff.
Specifically in regards to your question, this link should help: Automate PowerPoint from C#. EDIT LINK NOW DEAD :(. These two links are fairly close to the original KB article:
Automate Powerpoint from C# 1/2
Automate Powerpoint from C# 2/2
Finally, to whoever downvoted this: We were all learning one day, how to do something as a beginner is most definitely programming related, regardless of how new someone might be.
OpenXML looks like the way to go from a web app.
Using the interop libraries is not recommended, as others have stated.
You can also look at Aspose Slides, a component for .NET and Java that makes it easy to generate powerpoint documents.
If you don't really need PowerPoint compatible output, consider using a markup language such as LaTeX with the Beamer package to produce a PDF of the presentation, or use HTML and javascript in a manner similar to Slidy. If you need fancy effects, it might still be easier to use SVG, and you'd have the benefit of getting output that can be reliably viewed with free software.
http://msdn.microsoft.com/hi-in/magazine/cc163471(en-us).aspx
Use this link. Although this is in VB.NET, C# supports the same.
You may also try out SlideMight, a tool for merging hierarchical data with PowerPoint templates.
SlideMight supports:
text substitution in text fields, tables and notes
image substitution, from raw data, files and URLs
images in tables nested
iterations over data to create slides
iterations to populate tables, possibly spanning multiple slides
special formatting for specific cell values
hyperlinks to generated slides
Input data format is at this time just JSON.
There are versions for Windows and Mac OS X.
More information is at http://www.SlideMight.com
Disclaimer:
I am the owner of Delftware Technology, the company that developed SlideMight.
And I am one of the developers.
You can use Essential Presentation product from Syncfusion Software Private Limited. This product can be used to
Create and manipulate PowerPoint presentations
Open, modify, and save existing PowerPoint presentations
Convert PowerPoint presentations to PDF or Image
More information is at https://help.syncfusion.com/file-formats/presentation/overview
Disclaimer:
I work for Syncfusion Software Private Limited
Is there any good way to use a windows application written in C# to display/control a powerpoint slideshow? Ultimately I would like to show thumbnails in a form and clicking these thumbnails would advance the slides shown on a second monitor (similar to using Powerpoint itself to show a slideshow on a second monitor).
I would like to be able to use Powerpoint Viewer if Powerpoint is not installed.
There seems to be some ActiveX-controls that allows integration of Powerpoint in a form, but most of these seem to cost money, does anyone have experience using one of these controls?
Edit: I know that there is an object model accessable by adding a reference to Microsoft.Office.InterOp.Powerpoint, but I want to be able to distribute the resulting program without having Microsoft Office as a prerequisite, that was why I mentioned Powerpoint Viewer because it can be distributed freely.
This kb lays out the basics for working with the powerpoint presentation viewer object model. I'd suggest you include the viewer when you distribute your application.
http://support.microsoft.com/kb/265385
Once you get a reference to the viewer (top level) object it is basically the same as working with the powerpoint.presentation object model, but with less functionality (i.e. editing, etc)
If you are working with Powerpoint 2007, then you can add editing functionality by using the System.XML and related namespaces to work with the presentation file as an open xml file.
Regarding the comments about UNO/openoffice.org, I think these miss the point, as you cannot use UNO for working with powerpoint, it is for openoffice and that was not the origianl requirement of the questioner.
there are 3rd party toolsets like aspose, but then your goal was to work with the powerpoint viewer component (free) so I'm guessing you want to avoid paying for dev tools? Either way viewer components OM is perfectly suitable for displaying and previewing and existing slide show. (you will need one copy of Powerpoint so that you can author the presentation from scratch, plus Visual Studio to create the VSTO project).
One of our softwares here at work does that. Initially we used MS Office but recently we switched to use OpenOffice.org Uno since it offers better control than MS Office and is easier to work with. It has .NET CLI-bindings.
To answer your question, yes it can be done but our engineers would recommend you use OpenOffice.org instead.
Just like with Microsoft Excel and Word, Powerpoint has an Object Model that you can access in code by including a reference in your project to:
Microsoft.Office.InterOp.Powerpoint.
I've used the Excel and Word models, but haven't used the one for Powerpoint. You can get a little taste of what's available by opening up the Object Browser once you've included the reference to see what kind of functionality is available. This might be a viable solution for you if you don't want to use a 3rd party tool to access the object model.
I have used the Word toolkit from Aspose -- they have a Powerpoint toolkit too that I think would be worth looking at.
http://www.aspose.com/categories/file-format-components/aspose.slides-for-.net-and-java/default.aspx