Classic ASP and Formatting

I am using classic asp and I have 2 issues:

  1. want to set the style of a paragraph to one in my word document. The style is called “e-indent-nospace”. How do I do this? Here is a code snippet.
set asposeLicense = Server.CreateObject("Aspose.Words.License")
call asposeLicense.SetLicense(Server.Mappath("Aspose.Words.lic"))
set comHelper = Server.CreateObject("Aspose.Words.ComHelper")
set builder = CreateObject("Aspose.Words.Documentbuilder")
set docSource = comHelper.Open(dirTemplates + bookStem + ".doc")
builder.Document = docSource
call builder.moveToParagraph(1, -1)
'-- set a user defined style of "e-indent-nospace"
docSource.Save(dirOutputEBook + filestem + ".pdf")
  1. I want to get all my fonts in an ePub and I was told to use the following, however I am using classic ASP with the code listed above. How would I do the following in classic asp?
Document doc = new Document(@"c:\test\pan-boilerplate-ebook.doc");
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.SaveFormat = SaveFormat.Epub;
saveOptions.ExportFontResources = true;
doc.Save(@"C:\test\outWithFontsEmbedded.epub", saveOptions);

Kinds Regards,
-U

Hi Christina,

Thanks for your query. We are working over your query and will update you asap.

Hi Christina,

Thanks for your patience.

Regarding the question you asked in your second point, you need to create a wrapper class in C#/VB.NET if you want to use Aspose.Words for .NET via COM Interop in classic ASP. For example, you can create a wrapper that uses latest Aspose.Words for .NET assembly as follows:

  1. Open Visual Studio and create “Class Library” project and add a reference to latest Aspose.Words assembly.
  2. Create method, which accepts two parameters (input document path and output document path). Here is source code of the wrapper:
namespace AsposeComWrapper
{
    public class Methods
    {
        public Methods()
        {}
        public void ExportToEpub(object inPath, object outPath)
        {
            Document doc = new Document((string) inPath);
            HtmlSaveOptions saveOptions = new HtmlSaveOptions();
            saveOptions.SaveFormat = SaveFormat.Epub;
            saveOptions.ExportFontResources = true;
            doc.Save((string) outPath, saveOptions);
        }
    }
}
  1. Now, you should make your class library signed and visible for COM.
  2. After building the project, you should register the DLL using the following command:
regasm / codebase AsposeComWrapper.dll 
  1. Once your helper DLL is registered, you can use it to export Word document to EPUB. Here is sample code:
<%
Dim lic
Set lic = CreateObject("Aspose.Words.License")

lic.SetLicense("C:\test\Aspose.Words.lic")
Dim comHelper
Set comHelper = CreateObject("AsposeComWrapper.Methods")
comHelper.ExportToEpub "C:\test\pan-boilerplate-ebook.doc", "C:\test\out.epub"

%>

I hope, this will help.

Best Regards,

Hi Christina,

Regarding your first question (want to set the style of a paragraph to one in my word documen). Please use the same approach shared by Awais. Please use the following code snippet to set style of paragraph in ASP.

namespace AsposeComWrapper
{
    public class Methods
    {
        public Methods()
        {}
        public void ExportToEpub(object inPath, object outPath)
        {
            Document doc = new Document((string) inPath);
            HtmlSaveOptions saveOptions = new HtmlSaveOptions();
            saveOptions.SaveFormat = SaveFormat.Epub;
            saveOptions.ExportFontResources = true;
            doc.Save((string) outPath, saveOptions);
        }
        public void ParagraphFormat(object doc, object builder, object stylename)
        {
            Style style = ((Document) doc).Styles.Add(StyleType.Paragraph, (string) stylename);
            style.Font.Name = "Verdana";
            style.Font.Size = 15;
            // Apply the paragraph style to the current paragraph in the document and add some text.
            ((DocumentBuilder) builder).ParagraphFormat.Style = style;
        }
    }
}

Asp Code:

<%
Dim doc1
Set doc1 = CreateObject("Aspose.Words.Document")
Dim builder
set builder = CreateObject("Aspose.Words.Documentbuilder")
Dim comHelper
Set comHelper = CreateObject("AsposeComWrapper.Methods")
builder.Document = doc1
comHelper.ParagraphFormat doc1, builder, "MyStyle1"
builder.write "Aspose.Words"
doc1.save "c:\out.docx"
%>