Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Nov 07, 2012 3:17 pm

I am busy evaluating Spire.Doc. My scenario is as follows:

The site is an ASP.Net V4 site and I have a page (.aspx) which is already populated with data froma database. I cannot use LoadFromFile as the .aspx file first needs to be executed to populate the data.

I was thinking of having a seperate page to call the populated file and write it to stream so that the visitor can download the results as a .docx file.

Could you perhaps supply me with a sample project on how to do this.

Thanks in advance.

vdykcj
 
Posts: 6
Joined: Tue Nov 06, 2012 6:39 pm

Thu Nov 08, 2012 6:26 am

Hi vdykcj,

Thanks for you evaluating Spire.Doc.
According to your description, we think that you want to convert the .aspx file to a html file, then use LoadFromFile method of spire.doc to load the html file and save a .docx file so that your customers download the results as a .docx file. We are right? If we understand it correctly, we can provide a demo for you. If there is any misundstanding from us, please get back to us with more information about your requirement. And we will get an effective solution for you. Thanks.

Best regards,
Amy
E-iceblue support
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Nov 08, 2012 8:50 am

Hi Amy

Thank you for your response. I have attached a small example. When the page (default.aspx) is accessed by a client, s/he should be prompted to open/save the word document, which is the results of the page named PageToBeSavedAsDoc.aspx

vdykcj
 
Posts: 6
Joined: Tue Nov 06, 2012 6:39 pm

Fri Nov 09, 2012 8:56 am

Hi vdykcj,

According to your requirement, we provide a demo for you, please check the attachment demo.zip. If you have any problem, please feel free to contact us.

Best regards,
Amy
E-iceblue support
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Nov 09, 2012 9:31 am

Amy,

Thank you very much, exactly what I was looking for. :P

Cheers,
Johan
Cheers,
Johan

vdykcj
 
Posts: 6
Joined: Tue Nov 06, 2012 6:39 pm

Sun Nov 11, 2012 2:28 pm

Hi Amy

In my attached sample, how can I:
1. Specify an external stylesheet as the .docx file seems to be missing the styles from my stylesheet (see line 31/32 in .cs file).
2. Add a pagebreak ( see comment on lines 30 and 72 in attcahed .aspx file)
3. Add a header and footer which contain text and an image
4. If an image width/height is specified, it seems to be ignored by Spire.doc (see .aspx file - I specified the width/height but in the resulting .docx file all images appear the same size)

Your quick response will be appreciated. Thanks in advance.
Cheers,
Johan

vdykcj
 
Posts: 6
Joined: Tue Nov 06, 2012 6:39 pm

Mon Nov 12, 2012 8:27 am

Hi Johan,

Thanks for your inquiry.
Please don't mind that we add the answers after your problems. About the functionalities which we don't support at present, we are sorry for the inconvenience. We will add the functionalities in subsequent versions of spire.doc. Once the version has been released, we will inform you immediately.

1. Specify an external stylesheet as the .docx file seems to be missing the styles from my stylesheet (see line 31/32 in .cs file).

We are sorry that spire.doc doesn't support the functionality at present.

2. Add a pagebreak ( see comment on lines 30 and 72 in attcahed .aspx file).

We are sorry that spire.doc doesn't support the functionality at present.

3. Add a header and footer which contain text and an image.

Spire.doc supports adding a header and footer which contain text and an image to a doc/docx file. We provide you with some sample code.
Code: Select all
   static void InsertHeaderAndFooter(Section section)
    {   
        HeaderFooter header = section.HeadersFooters.Header;
        HeaderFooter footer = section.HeadersFooters.Footer;

        //insert picture and text to header
        Paragraph headerParagraph = header.AddParagraph();
        DocPicture headerPicture= headerParagraph.AppendPicture(Image.FromFile(@"Header.png"));

        //header text
        TextRange text = headerParagraph.AppendText("Demo of Spire.Doc");
        text.CharacterFormat.FontName = "Arial";
        text.CharacterFormat.FontSize = 10;
        text.CharacterFormat.Italic = true;
        headerParagraph.Format.HorizontalAlignment= Spire.Doc.Documents.HorizontalAlignment.Right;

        //border
        headerParagraph.Format.Borders.Bottom.BorderType= Spire.Doc.Documents.BorderStyle.Single;
        headerParagraph.Format.Borders.Bottom.Space = 0.05F;

        //header picture layout - text wrapping
        headerPicture.TextWrappingStyle = TextWrappingStyle.Behind;

        //header picture layout - position
        headerPicture.HorizontalOrigin = HorizontalOrigin.Page;
        headerPicture.HorizontalAlignment = ShapeHorizontalAlignment.Left;
        headerPicture.VerticalOrigin = VerticalOrigin.Page;
        headerPicture.VerticalAlignment = ShapeVerticalAlignment.Top;

        //insert picture to footer
        Paragraph footerParagraph = footer.AddParagraph();
        DocPicture footerPicture = footerParagraph.AppendPicture(Image.FromFile(@"Footer.png"));

        //footer picture layout
        footerPicture.TextWrappingStyle = TextWrappingStyle.Behind;
        footerPicture.HorizontalOrigin = HorizontalOrigin.Page;
        footerPicture.HorizontalAlignment = ShapeHorizontalAlignment.Left;
        footerPicture.VerticalOrigin = VerticalOrigin.Page;
        footerPicture.VerticalAlignment = ShapeVerticalAlignment.Bottom;

        //insert page number
        footerParagraph.AppendField("page number", FieldType.FieldPage);
        footerParagraph.AppendText(" of ");
        footerParagraph.AppendField("number of pages", FieldType.FieldNumPages);
        footerParagraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Right;

        //border
        footerParagraph.Format.Borders.Top.BorderType = Spire.Doc.Documents.BorderStyle.Single;
        footerParagraph.Format.Borders.Top.Space = 0.05F;
    }

4. If an image width/height is specified, it seems to be ignored by Spire.doc .

We are sorry that spire.doc doesn't support the functionality at present.

Best regards.
Amy
E-iceblue support
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Nov 12, 2012 8:35 am

Thanks Amy

Any idea when Spire.Doc will support the missing functionality?

How can I overcome 1 & 2 or impliment differently to format the produced .doc?
Cheers,
Johan

vdykcj
 
Posts: 6
Joined: Tue Nov 06, 2012 6:39 pm

Tue Nov 13, 2012 8:35 am

Hi Johan,

We are sorry for your problem #1, #2 and #4, we can't provide you a simple solution at present, but our Develop team are working them at present. We try to fix #1 & #2 within this week. Is that ok ?

Best regards,
Amy
E-iceblue support
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Nov 13, 2012 8:39 am

Thanks Amy.

It will be great if 1 & 2 can be fixed this week.
Cheers,
Johan

vdykcj
 
Posts: 6
Joined: Tue Nov 06, 2012 6:39 pm

Fri Nov 16, 2012 10:28 am

Hi Johan,

Thanks for you waiting.
We have fixed 1&2, please download spire.doc_hotfix_4.5.16 from the link http://www.e-iceblue.com/downloads/hot_fix/spire.doc_hotfix_4.5.16.zip.
Please try to test it, and tell us how it works. Thank you!

Best regards,
Amy
E-iceblue support
Last edited by amy.zhao on Wed Nov 21, 2012 2:38 am, edited 1 time in total.
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Wed Nov 21, 2012 2:37 am

Hi Johan,

Thanks for you waiting.
We have fixed #4, please download Spire.Doc Pack (Hot Fix) Version:4.5.19 from the link http://www.e-iceblue.com/Download/download-word-for-net-now.html. Please try to test it, and tell us whether it has resolved the problem. Thank you! If you encounter any problem, please don't hesitate to contact us.

Best regards,
Amy
E-iceblue support
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc