Conversion Capabilities for Aspose.Total for .NET

Hi Aspose,

I am interested in Aspose.Total for .NET .Mainly for PDF Conversion I use.I would like to know the following details:

1.Is Aspose.Words for .NET is able to convert a document which is present in Sharepoint Document Library into PDF.I tested with normal website and get succeded but It didn’t work for me for Sharepoint Document Library.Have you tested this functionality.
2.My requirements for Aspose.Cells for .NET ,Aspoe .PDF for .NET also same as above and concerned with Sharepoint Document Linrary.

Please answer me.
Thanking You

Hi,

Thank you for your interest in our products.

Of course you can use Aspose.Words for .Net with SharePoint. Could you please show your code or provide more details about what did not work when converting a document from a SharePoint document library?

If you are primarily interested in document conversion, you can consider using Aspose.Words for SharePoint and other products from our SharePoint family. For example, Aspose.Words for SharePoint can convert SPFile or SPFolder object and save the result directly to a SharePoint document library.

SPWeb web = SPContext.Current.Web;

SPFile srcFile = web.GetFile("Shared Documents/sample.docx");

// Convert to RTF with default options.

ConvertedItem result =

Converter.ConvertFile(srcFile, srcFile.ParentFolder, SaveFormat.Pdf, null);

Please note that Aspose.Words for SharePoint and Aspose.Words for .Net are different products. Aspose.Words for SharePoint does not provide an API for changing a document programmatically via document object model.

Thanks & Best Regards,

I used the following code.It works fine for normal websites.But it didn't work for documents in sharepoint libraries.I think I have to pass the user credentials.I have done that also.Is this the right way to pass user credentials.Provide me with Sample code to convert HTML to PDF also.Kindly help with the code.


string url = @"shrepoint document library urlc";

//Prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.ContentType = "application/msword";
request.UserAgent = "Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0";
request.credentials = new Networkcredential(username,password");

//Execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

//We will read data via the response stream
Stream resStream = response.GetResponseStream();

//Write content into the MemoryStream
BinaryReader resReader = new BinaryReader(resStream);

MemoryStream docStream = new MemoryStream(resReader.ReadBytes((int)response.ContentLength));

Document doc = new Document(docStream);

//Save document to PDF
doc.Save(@"out.pdf");

Hi,

Thank you for the additional information.

I see that you call Aspose.Words.Document constructor on a stream. If the data in the stream is correct, Aspose.Words creates a document object. It does not matter if the data came from SharePoint or other source.

Your code for getting the stream data looks correct to me. I tried it and it works, with this line:

request.Credentials = new NetworkCredential(username, password);

Without this line or if the password is incorrect, I get System.WebException saying “The remote server returned an error: (401) Unauthorized.” Please check that you provide a valid user name and password.

If the problem persists, please post the exception and error message you get.

Thanks & Best Regards,

Hi Dimitry
Ok.Thank You Very Much,I will test it in the coming hours and tell you the results.
Now I have the problem of converting HTML to PDF.The example or coding which you given in documentation section are not that much good.Would you please provide a simple example about Converting HTML to PDF. Which tags are supported completely? and which are not supported?

Thanking You very much.

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your interest in Aspose.Words. You can try using the following code to convert your HTML to PDF:

// Load HTML document

Document doc = new Document("C:\\Temp\\Test.html");

// Save as PDF

doc.Save("C:\\Temp\\Test.pdf", SaveFormat.Pdf);

In additional, please follow the link to see the table which provides implementation details about how Aspose.Words saves a document in the PDF format.

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/save-in-the-adobe-portable-document-pdf-format.html

Best regards,

Hi Andrey,Now I have left with two issues.
1.
When I use Aspose.Words to convert document in a sharepoint library ,I am gettign an unexpected error.
I use SharePoint 2010,VS 2010 . and I deploy the package as WSP to the SharePoint.I have hardcoded username ,password for http Web Response.Would you check once the fucctionality in WSP package and let me know the results?

2.On aspose website where can I get the list of Html tags hat are supported by aspose

Thanking You Very much.


Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You can find an approximate list of what is supported in HTML import/export here:
http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/save-in-the-html-format.html

Regarding WSP, my colleague from developer team will take a look and answer you shortly.

Best regards,

Hi,

System.Net.HttpWebRequest works under SharePoint as well.

However, if you use it to get a file from the SharePoint server where you deploy your solution, this may not be the best option. You may consider using SharePoint object model to get the file data. Like this:

using Microsoft.SharePoint;

public void Test()

{

const string relativeFileUrl = @"Shared Documents\sample.docx";

SPFile file = SPContext.Current.Web.GetFile(relativeFileUrl);

using (Stream fileStream = file.OpenBinaryStream())

{

// Here you can use file data from the stream.

}

}

In this case, you will use the security context of the current user’s session.

Hope this helps. If you need further assistance, please provide more information on the error you get.

Thanks & Best Regards,