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.

Thu Nov 19, 2015 7:15 am

Hi,

I have a problem with sprire doc free edition.I'm developing MVC project with C# and I want to convert my docx document to PDF and I'm getting error.

My codes;
Code: Select all
  private static byte[] ConvertToPdf(MemoryStream memory)
        {
            memory.Position = 0;
            Document document = new Document();
            document.LoadFromStream(memory, FileFormat.Docx);
            var pdfStream = new MemoryStream();
            document.SaveToStream(pdfStream, FileFormat.PDF);
            pdfStream.Position = 0;
            byte[] bytesIBytes = pdfStream.ToArray();

            return bytesIBytes;
}

bora1891
 
Posts: 8
Joined: Thu Nov 19, 2015 6:58 am

Thu Nov 19, 2015 7:50 am

Hello,

Thanks for your inquiry.
To help us recreate your issue and resolve it soon, please provide us your docx document.

Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

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

Thu Nov 19, 2015 8:09 am

Hello,

Thanks for reply.

My problem is in Spire document has printDocument attribute.That attribute some times coming null.Why that attribute coming to null?.When I tried to other variable to call my template that attribute it's not coming to null.How can I control that one?.And How can I solve this problem?
Last edited by bora1891 on Thu Nov 19, 2015 9:07 am, edited 1 time in total.

bora1891
 
Posts: 8
Joined: Thu Nov 19, 2015 6:58 am

Thu Nov 19, 2015 8:53 am

Hi,

Please use the following code to print your word documents.
Code: Select all
 Document doc = new Document();
            doc.LoadFromFile("..\\..\\1.docx");   
            PrintDocument printDoc = doc.PrintDocument;
            printDoc.Print();


If you still have the issue, please provide us your document to help us do an investigation.

Best Regards,
Amy
E-iceblue support team
User avatar

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

Thu Nov 19, 2015 9:11 am

I add my document template before my answer and also I have to create PDF from stream because everything is my stream.Now when I debug my code I saw the pageCount and PrintDocument has an exception.Maybe loadstream is not load from my memoryStream ?

bora1891
 
Posts: 8
Joined: Thu Nov 19, 2015 6:58 am

Thu Nov 19, 2015 11:16 am

Thank you for your help.

I solve my problem.The problem is I use table in receursive element my template.And when address is too long the conversation make exception but docx document will work.Now I used Repeating content control in my problem and it solve the problem.

Thanks for help

bora1891
 
Posts: 8
Joined: Thu Nov 19, 2015 6:58 am

Fri Nov 20, 2015 1:38 am

Hi,

I am glad to hear that your issue has been resolved.
Welcome to write to us again if you have further problems.

Best Regards,
Amy
E-iceblue support team
User avatar

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

Return to Spire.Doc