Exception while uploading doc files in asp.net website

Hi

We are using Aspose API for word documents.

I am trying to upload new docs but it is throwing me exception errors.

I am attaching the two documents that i am trying to upload with this message.

Also Please find the “ErrorMessage.docx” with the message which shows the exact error i am getting while uploading those documents.

Please help me out over this.

Thanks Heaps

Sukhdeep

Hi,

Thank you for inquiry. While loading provided Word documents, i did not observe any problem.

Code snippet:

Document doc1 = new Document("c:/temp/Authority+to+Act+GENERAL+Feb+2012+Ellerslie.doc");
Document doc2 = new Document("c:/temp/Authority+to+Act+SOLE+Feb+2012+Ellerslie.doc");

Moreover, this is difficult for me to judge template object before details. Please visit document object description here.

DataSet ds = GetContent();
Document doc = template.Execute(ds);

Hope this will help. In case of any ambiguity, please let me know.

Hi Imran

Thanks for the quick reply.

Sorry there was mistake by me in the post.

We are getting error while writing over these templates.

Can you please cross check this.

Thanks Heaps

Hi

Thank you for details. I am still unable to reproduce any problem while loading, writing and saving. It would be great if you share code snippet here.

protected void btnProcess_OnClick(object sender, EventArgs e)
{
    int? documentTemplateId = Convert.ToInt32(ddlDocumentTemplate.SelectedValue);
    if (documentTemplateId != null && Page.IsValid)
    {
        DocumentTemplate documentTemplate = new DocumentTemplateService().GetByDocumentTemplateId((int)documentTemplateId);

        string templateFilename = HttpContext.Current.Server.MapPath(documentTemplate.Filename);
        //string templateFilename = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + documentTemplate.Filename;

        if (templateFilename != null)
        {
            //Create and execute the demo, it produces a document in memory.
            Template template = new Template();
            template.DocPath = templateFilename;

            DataSet ds = GetContent();

            Document doc = template.Execute(ds);

            DocumentBuilder builder = new DocumentBuilder(doc);

            #region Insert Image(Listing and broker)
            nmmain.Broker_Listing_Image obj = new nmmain.Broker_Listing_Image();
            DataTable dt = new DataTable();
            LinkWebsiteConfigurationSection config = LinkWebsiteConfigurationSection.Instance;
            string imageUrl = null;
            object imageFilename = null;
            object imageResourceId = null;

            if (brokerimage == Convert.ToBoolean("true"))
            {
                builder.MoveToMergeField("vbrokerimage");
                //if (builder.MoveToMergeField("vbrokerimage") == true)
                //{
                dt = obj.GetBrokerImage(broker_id);
                if (dt.Rows.Count > 0)
                {

                    imageFilename = dt.Rows[0]["brokerimage"];
                    imageResourceId = dt.Rows[0]["ImageResourceId"];
                    if ((imageFilename != DBNull.Value) && (imageResourceId != DBNull.Value))
                        imageUrl = ImageResource.GetImageUrl("", siteurl + "UploadedContent/Images/", (int)imageResourceId, (string)imageFilename, ImageResource.ImageFileSize.Orig);

                    builder.InsertImage(imageUrl, 120, 123);//,

                    // Aspose.Words.Drawing.RelativeHorizontalPosition.Margin,
                    // -448,
                    // Aspose.Words.Drawing.RelativeVerticalPosition.Margin,
                    // 46,
                    // -1,
                    // -1,
                    // Aspose.Words.Drawing.WrapType.None);
                }
                else
                {

                    builder.InsertImage(siteurl + "/Images/no_avatar.gif");//,
                                                                                //Aspose.Words.Drawing.RelativeHorizontalPosition.Margin,
                                                                                //-448,
                                                                                //Aspose.Words.Drawing.RelativeVerticalPosition.Margin,
                                                                                //46,
                                                                                //-1,
                                                                                //-1,
                                                                                //Aspose.Words.Drawing.WrapType.None);
                }
                //}
            }
            else
            {
                builder.MoveToMergeField("vbrokerimage");
                builder.InsertHtml("");
                //builder.InsertImage(siteurl + "/Images/space.gif");//,
                // Aspose.Words.Drawing.RelativeHorizontalPosition.Margin,
                // -448,
                // Aspose.Words.Drawing.RelativeVerticalPosition.Margin,
                // 46,
                // -1,
                // -1,
                // Aspose.Words.Drawing.WrapType.None);
            }
            //builder.MoveToDocumentEnd();

            if (listingimage == Convert.ToBoolean("true"))
            {
                builder.MoveToMergeField("vlistingimage");
                //if (builder.MoveToMergeField("vlistingimage") == true)
                //{

                dt = obj.GetListingImage(listing_id);
                if (dt.Rows.Count > 0)
                {

                    imageFilename = dt.Rows[0]["listingimage"];
                    imageResourceId = dt.Rows[0]["ImageResourceId"];
                    if ((imageFilename != DBNull.Value) && (imageResourceId != DBNull.Value))
                        imageUrl = ImageResource.GetImageUrl("", siteurl + "UploadedContent / Images /", (int)imageResourceId, (string)imageFilename, ImageResource.ImageFileSize.Small);
                    builder.InsertImage(imageUrl, 120, 123);//,
                                                            //Aspose.Words.Drawing.RelativeHorizontalPosition.Margin,
                                                            //-35,
                                                            //Aspose.Words.Drawing.RelativeVerticalPosition.Margin,
                                                            //50,
                                                            //120,
                                                            //120,
                                                            //Aspose.Words.Drawing.WrapType.None);
                }
                else
                {
                    builder.InsertImage(siteurl + "/Images/no_Listing.gif");//,
                                                                                // Aspose.Words.Drawing.RelativeHorizontalPosition.Margin,
                                                                                // -10,
                                                                                // Aspose.Words.Drawing.RelativeVerticalPosition.Margin,
                                                                                // 50,
                                                                                // -1,
                                                                                // -1,
                                                                                // Aspose.Words.Drawing.WrapType.None);
                }
                //}

            }
            else
            {
                builder.MoveToMergeField("vlistingimage");
                builder.InsertHtml("");
                //builder.InsertImage(siteurl + "/Images/space.gif"); //space,
                // Aspose.Words.Drawing.RelativeHorizontalPosition.Margin,
                // -10,
                // Aspose.Words.Drawing.RelativeVerticalPosition.Margin,
                // 50,
                // -1,
                // -1,
                // Aspose.Words.Drawing.WrapType.None);
            }
            #endregion
            SendToBrowser(doc, "DOC", documentTemplate.Title);

            Response.End();
        }
    }
    else
    {

        DataSet ds = new DocumentTemplateService().Search(CurrentUserID, OfficeSelector1.OfficeId);
        if (ds.Tables.Count > 0)
        {
            AttachJavascript(ds.Tables[0]);
        }
    }
}

Hi Imran

Did you get a chance to review the above code snippet that we are using… Please let us know over this ASAP. we need it to be resolved urgently

Thanks

Sukhdeep

Hi,

Thanks for your inquiry.I’m afraid we are unable to reproduce that issue on our side because of missing dll. Could you please create a simple console application which reproduces the issue on your side and attach it here? We will take a closer look into what’s happening and provide you with some further feedback.