create ppt programmatically using C# [duplicate] - c#

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

Related

How to convert office file to image

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/)

Complex reports from C# programatically into office Word

First of all I want to say hi to the programming community, what I am looking for is a way to generate a report from my Windows Forms Application in word preferably, this report is basically a list of pre-configured days in a tour creation software I am creating.
I have searched everywhere and I cant seem to find information on how to start creating the report, I have all the information saved into a database, I just need to be able to get this information into word and ordered as it should be ordered.
I just want to be pointed in the right direction so I can research on it even further.
The exact thing I want to create is a word file that I wish I could share here so you can actually see what I mean.
Thank you for all your attention and help if possible.
I can point you in the right direction. Word documents are stored in a format called OpenXml which can be created and manipulated without actually using Word directly. That's good because you don't want to deal with code that actually starts an instance of Word and automates it (Interop.) It sort of works but it's not something I recommend dealing with ever.
OpenXml isn't fun either, but it's better. You can create your document "normally" using Word, save it, and then have your application use it as a template, opening a copy, populating some data, and then saving it.
Here's the reference for OpenXml with Word. I'm not saying it's pretty. It's not. The documentation is lacking. This page on adding text isn't linked from the previous page, even though many other topics are.
There are some nuget packages like this one that can help.
I once did a POC that did exactly what you're describing by opening and altering a document used a template using OpenXml. I'll see if I can dig up the code. But this is definitely a good direction to look in if Word is an absolute requirement.
This is a long shot, but can you output in HTML? If you can that's an even easier alternative.
Can you use Excel? That's also OpenXml but there's easier-to-use tools like EPPlus that simplify dealing with it, because it's not just the friendliest thing to work with.
An option that I would suggest is Crystal Reports. You can download the Crystal Reports add-in for Visual Studio for free from here. Crystal Reports is an easy way to perform reporting from various data sources including SQL. There are also a lot of free tutorials online for learning how to use CR. The syntax is a little strange, but it is easy enough to use.
The add-in allows you to create reports for your application and also build applications that can display, print, and export Crystal Reports.
You can export reports to .RTF (Rich Text Format) files. MS Word can open, edit, and convert RTF documents. It does a fairly decent job, but special formatting might take some work. This route is a ton easier than trying to write XML or anything else. I've written several reports designed for export to RTF. My boss runs the report, exports it, then edits it in Word. He loves the reports.
If you are planning on developing a lot of reports, purchasing the full version of Crystal Reports is well worth it. I believe they are on version 2016 currently.
If you do want to deal with automating Word, Microsoft's guide "Automating Applications Using the Office Object Model" Word-specific task content is here: https://msdn.microsoft.com/en-us/library/78whx7s6(v=vs.80).aspx
A larger example: https://support.microsoft.com/en-us/kb/316384
To begin, simply add an assembly reference to your project file for the correct Office Object Library (example: "Microsoft Word ##.0 Object Library"). Note that you must have Office installed to take this approach.
Good luck!

printing in WPF - making your own 'bill' - any directions?

I am wondering the best way to make bills, or reports or anything printing related in WPF. I am thinking of using iTextSharp but I wanna see what other ways are there. Can anyone here direct me in the right way? Thanks in advance!
If you are coding for POS(Point Of Sale) System, then you can use System.Drawing.Printing Library for printing bill, which is really fast.
For reports, use crystal reports for dynamic pdf reports generation because you can export it to pdf, excel and rpt.
The OpenXML SDK is Microsoft's own library for working with Office (> 2007) documents: http://www.microsoft.com/en-gb/download/details.aspx?id=30425 . It's reasonably straightforward to use, and comes with the handy 'OpenXMLSDKTool' which takes existing Office files and creates the source code required to generate them.

Server side library for conversion of office files to pdf with added stamp/watermark

I need to take Word, Excel, PowerPoint and Visio files and convert them to PDF on the server side using C#.
At some point before or after the PDF conversion, the clients want a stamp/watermark to be added to the corner of the document (assuming, for now, on every page).
I cannot use Office products in the process, as there are licensing and stability issues involved with using "interop" server-side. Also, I would rather not depend on any other installed software on the server for similar reasons; this functionality will be used by multiple clients at the same time.
I have spent a couple of days searching, and
Aspose seems to be the only library which would be suitable, however it seems prohibitively expensive. I would welcome any suggestions which would complete all requirements, or separate libraries to handle the watermark and conversion to PDF separately
UPDATE: As of now I have a prototype converting all the above file types to pdf with a watermark added using Aspose. It was relatively easy, the forum can be a great help when in a pickly
I think AbcPDF will do this for about half the price: http://www.websupergoo.com/abcpdf-office-docs.htm
You might have to roll the watermark part yourself, but that's quite trivial to code.
There is also quite a list of libs here: .NET server based PDF generation

Word document generation

Our product is going to support Word(and PDF) report generation, and I'm investigating on which techniques to choose.
Currently what I know is Word automation and OpenXML SDK. There are pros & cons of each.
Do you have any experiences, suggestions or comments about these two or any other techniques? Or is there any third-party utilities/products(may be based on the previous two techniques or not) we can use? We want to analyze as many possible solutions as possible.
If you have the choice I'd go for OpenXML any day of the week.
It has quite a number of advantages over Office Automation.
The most interesting one for me is the fact that it can run on a server, where Office Automation can't (because you need an instance of office on the pc/server running your software). That brings us to my second point, it doesn't need an instance of Office to generate your documents, where Office automation needs one. (This is because office automation will run an instance of office in the background and perform all your actions on it).
Especially when we are talking about large documents or being able to generate quite a few at the same time, OpenXML will perform a lot better than Office Automation because of this.
To make a long story short, Office automation is a thing of the past, openXML is the future ;)
If you want to dive into OpenXML, take a peek here: OpenXML Developer
Good luck !
For PDF generation I used http://www.html-to-pdf.net in past. This provides good support and I assume can be used to generate word documents as well... Check out there website...
If you are using Web forms, I faced one issue with HTTPS - which I listed the solution here:
http://blogs.msdn.com/b/sajoshi/archive/2010/12/13/using-pdfconverter-http-www-html-to-pdf-net-with-https-in-asp-net-mvc.aspx
Docmosis offers a cloud service that can produce MS Word and PDF output via a simple api. The report or document templates are either Word or Open Office documents which can be edited and maintained by non-developers. Once uploaded to the system your application can then simply call the service and specify the data to inject into the document(s) as either JSON or XML. The result is then streamed back, emailed, or placed in storage for access later. Output can be doc, pdf, or html.
The service offers a wide range of templating features and so supports quite complex reporting requirements.
The best thing we found was that cosmetic changes to the output could be handled by the document authors and not the developers which saved us heaps of valuable time (not to mention saving the sanity of our developers).
www.docmosis.com
If you want to build your documents in code, the OpenXML SDK is definitely the way to go. It is a very well designed API that makes full use of LINQ type syntax. One you're up to speed on it you will find it very powerful and easy to use.
With that said, you then have all the logic of your document in code. And change requires a change in your code and that tends to become a pain over time. If you want a system where you design the document in Word you've got a couple of choices - and Word automation is the worst. Even Microsoft says don't do Office automation on a server.
One of the best choices where you design in Word is Windward Reports (disclaimer - I'm the CTO there). With Windward you get the power and ease of Word for your design and new documents or revisions of existing documents don't require a change in code. Other products that take this approach are XpertDoc and SoftArtisans (although both of them do have a code component with each template).

Categories