We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF.Save

I am having an issue with saving a PDF. Here is what I am doing

I populate an XML with values from my DB, then I save the XML on the DB for future or insyant processing, I call an aspx page to display it from the browser. Here is my code

The XML is about 16,000 characters, I am using IIS7, windows 2008 R2 all of this is inside the MSCRM 4.0 framework which is basically asp.net

also if I use images from my DB it will take a long time and use most of my server resources and then time out.

Here is the error

An error occurred while communicating with the remote host. The error code is 0x800703E3.

Please help.

DynamicEntity pp = new DynamicEntity(“awx_particular”, this.ObjectId);
XmlDocument xml = new XmlDocument();
xml.LoadXml(pp.GetPropertyValue(“awx_xmldata”));

Pdf pdf = new Pdf();

pdf.BindXML(xml, null);

pdf.Save(“PropertyParticular.pdf”, SaveType.OpenInAcrobat, this.Context.Response);


XML File Attached



Hello Fernando,

As far as I can see from the error message, the issue is occurring while accessing contents from remote server. May be you can try using the TimeOutOfFileWebRequest static property of Pdf class to set the length of time until the request times out for the Pdf document.

However, when I have tried converting the attached file into PDF format, I am getting an error message "Data at the root level is invalid. Line 1, position 1.". Can you please take a look over the attached document.

In case it does not resolve your problem or you have any further query, please feel free to contact. We apologize for your inconvenience.

I fixed the problem with the XML, and also I figured that having the file open on a modal page does not work.

I do however still have a lingering problem which is that when I replace the images from a template with an image in memory the PDF takes a long time to render. Here is the code I am using and maybe you can suggest a different approach to improve performance.

Scenario:
We store the pictures in our DB on a ntext file, we store a base64 string which represents a binary array derived from the image itself. Then when we render the PDF we locates the images that need to be replaced by using the ID attribute of the Image on the XML

Process:

We load the base64 string into a a class and process it and then extract the bytes into a stream to replace the images here is the code.

We loop the images and call this function:

private void ReplaceImage(Pdf pdf, string id, Byte[] bytes)
{
Image oldImage = (Image)pdf.GetObjectByID(id);
Cell cell = (Cell)pdf.GetObjectByID(“cell” + id);

if (oldImage != null && cell != null)
{
Image newImage = new Image();

cell.Paragraphs.Insert(oldImage, newImage);
cell.Paragraphs.Remove(oldImage);

newImage.Left = oldImage.Left;
newImage.ImageInfo.FixHeight = oldImage.ImageInfo.FixHeight;
newImage.ImageInfo.FixWidth = oldImage.ImageInfo.FixWidth;
newImage.ImageInfo.ImageFileType = oldImage.ImageInfo.ImageFileType;
newImage.ImageInfo.ImageStream = new MemoryStream(bytes);
}
}

Finally we save the PDF

pdf.Save(“PropertyParticular.pdf”, SaveType.OpenInBrowser, this.Context.Response);