Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6657349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:45:25+00:00 2026-05-26T01:45:25+00:00

Ok before you think Not another question like this please read this first. I

  • 0

Ok before you think “Not another question like this” please read this first.

I have an application (web application in ASP.NET MVC 3) the generates Word files in DocX using the DocX library.

The application takes a template and fills it in with all the data from a database.
Now I want to create a PDF version of that created docx-file.

I know apose.word is an option, but not for me since I have little budget. Other libs where I have to spend some money on are also out of the question.

I don’t have a sharepoint server so Word Automation Services isn’t an option either.

So I have 2 options (that I know) left and they both use iTextSharp. Don’t know which is better.

  1. I could use the generated XML from the docx file and transform it to a version that is usable by iTextSharp.
  2. I could create the PDF like I create the docx with a template.

Anybody has any idea on how much work it is, which of those 2 has better performance and if it is even possible to do.

I know that the second option has the downside that when I change a template I have to change it for both versions.

If you have a better solution (free that is), you are welcome to share it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:45:26+00:00Added an answer on May 26, 2026 at 1:45 am

    Another option, even if it needs some work: install OpenOffice on server and, using UNO libraries (including them as assemblies in your app), you can open docx document and save it in PDF directly.
    In a few minutes I post an example…

    PARTIAL EXAMPLE:
    This is a class I created a long time ago and used to convert files to pdf

    using unoidl.com.sun.star.lang;
    using unoidl.com.sun.star.uno;
    using unoidl.com.sun.star.container;
    using unoidl.com.sun.star.frame;
    using unoidl.com.sun.star.beans;
    using unoidl.com.sun.star.view;
    using System.Collections.Generic;
    using System.IO;
    
    namespace QOpenOffice
    {
        public enum AppType
        {
            Writer,
            Calc,
            Impress,
            Draw,
            Math
        }
    
        public enum ExportFilter{
            Word97,
            WriterPDF,
            CalcPDF,
            DrawPDF,
            ImpressPDF,
            MathPDF
        }
    
        class OpenOffice
        {
            private XComponentContext context;
            private XMultiServiceFactory service;
            private XComponentLoader component;
            private XComponent doc;
    
            private List<string> filters = new List<string>();
    
            #region Constructors
            public OpenOffice()
            {
                /// This will start a new instance of OpenOffice.org if it is not running, 
                /// or it will obtain an existing instance if it is already open.
                context = uno.util.Bootstrap.bootstrap();
    
                /// The next step is to create a new OpenOffice.org service manager
                service = (XMultiServiceFactory)context.getServiceManager();
    
                /// Create a new Desktop instance using our service manager
                component = (XComponentLoader)service.createInstance("com.sun.star.frame.Desktop");
    
                // Getting filters
                XNameContainer filters = (XNameContainer)service.createInstance("com.sun.star.document.FilterFactory");
                foreach (string filter in filters.getElementNames())
                    this.filters.Add(filter);
            }
    
            ~OpenOffice()
            {
                if (doc != null)
                    doc.dispose();
                doc = null;
            }
            #endregion
    
            #region Private methods
            private string FilterToString(ExportFilter filter)
            {
                switch (filter)
                {
                    case ExportFilter.Word97: return "MS Word 97";
                    case ExportFilter.WriterPDF: return "writer_pdf_Export";
                    case ExportFilter.CalcPDF: return "calc_pdf_Export";
                    case ExportFilter.DrawPDF: return "draw_pdf_Export";
                    case ExportFilter.ImpressPDF: return "impress_pdf_Export";
                    case ExportFilter.MathPDF: return "math_pdf_Export";
                }
                return "";
            }
            #endregion
    
            #region Public methods
            public bool Load(string filename, bool hidden)
            {
                return Load(filename, hidden, "", "");
            }
            public bool Load(string filename, bool hidden, int filter_index, string filter_options)
            {
                return Load(filename, hidden, filters[filter_index], filter_options);
            }
            public bool Load(string filename, bool hidden, string filter_name, string filter_options)
            {
                List<PropertyValue> pv = new List<PropertyValue>();
                pv.Add(new PropertyValue("Hidden", 0, new uno.Any(hidden), PropertyState.DIRECT_VALUE));
                if (filter_name != "")
                {
                    pv.Add(new PropertyValue("FilterName", 0, new uno.Any(filter_name), PropertyState.DIRECT_VALUE));
                    pv.Add(new PropertyValue("FilterOptions", 0, new uno.Any(filter_options), PropertyState.DIRECT_VALUE));
                }
    
                try
                {
                    doc = component.loadComponentFromURL(
                        "file:///" + filename.Replace('\\', '/'), "_blank",
                        0, pv.ToArray());
                    return true;
                }
                catch
                {
                    doc = null;
                    return false;
                }
            }
            public bool Print()
            {
                return Print(1, "");
            }
            public bool Print(int copies, string pages)
            {
                List<PropertyValue> pv = new List<PropertyValue>();
                pv.Add(new PropertyValue("CopyCount", 0, new uno.Any(copies), PropertyState.DIRECT_VALUE));
                if (pages != "")
                    pv.Add(new PropertyValue("Pages", 0, new uno.Any(pages), PropertyState.DIRECT_VALUE));
                //if (doc is XPrintable)
                try
                {
                    ((XPrintable)doc).print(pv.ToArray());
                    return true;
                }
                catch { return false; }
            }
            public bool Save(string filename, ExportFilter filter)
            {
                return Save(filename, FilterToString(filter));
            }
            public bool Save(string filename, string filter)
            {
                List<PropertyValue> pv = new List<PropertyValue>();
                pv.Add(new PropertyValue("FilterName", 0, new uno.Any(filter), PropertyState.DIRECT_VALUE));
                pv.Add(new PropertyValue("Overwrite", 0, new uno.Any(true), PropertyState.DIRECT_VALUE));
                try
                {
                    filename = filename.Replace("\\", "/");
                    ((XStorable)doc).storeToURL("file:///" + filename, pv.ToArray());
                    return true;
                }
                catch { return false; }
            }
            public bool ExportToPdf(string filename)
            {
                filename = Path.ChangeExtension(filename, ".pdf");
                bool ret = Save(filename, "writer_pdf_Export");
                if (!ret) ret = Save(filename, "impress_pdf_Export");
                if (!ret) ret = Save(filename, "calc_pdf_Export");
                if (!ret) ret = Save(filename, "draw_pdf_Export");
                if (!ret) ret = Save(filename, "impress_pdf_Export");
                if (!ret) ret = Save(filename, "math_pdf_Export");
                return ret;
            }
            public void Close()
            {
                doc.dispose();
                doc = null;
            }
    
            public bool New(AppType app, bool hidden)
            {
                try
                {
                    string sapp = "private:factory/";
                    switch (app)
                    {
                        case AppType.Writer:
                            sapp += "swriter";
                            break;
                        case AppType.Calc:
                            sapp += "scalc";
                            break;
                        case AppType.Impress:
                            sapp += "simpress";
                            break;
                        case AppType.Draw:
                            sapp += "sdraw";
                            break;
                        case AppType.Math:
                            sapp += "smath";
                            break;
                    }
                    PropertyValue pv = new PropertyValue("Hidden", 0, new uno.Any(hidden), PropertyState.DIRECT_VALUE);
                    doc = component.loadComponentFromURL(sapp, "_blank", 0, new PropertyValue[1] { pv });
                    return true;
                }
                catch
                {
                    doc = null;
                    return false;
                }
            }
            #endregion
    
    
            #region Properties
            public List<string> Filters
            {
                get { return filters; }
            }
            #endregion
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys before you start down voting me please read this question and please understand
This question is about limits imposed to me by ASP.NET (like script timeout etc').
In ASP.NET MVC I have a controller that looks somehow like this: public class
I think the question is pretty self explanatory. Anyone done this before? UPDATE :
I don't think this question has been asked before. I'm a bit confused on
I asked this question before, Here however I think I presented the problem poorly,
I have tried to ask a variant of this question before. I got some
Effort I've read this question , but I still think there has to be
I know questions like this have been asked before, and I've viewed a lot
I think I didn't clearly asked this question before (because I didn't get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.