Need a product to purchase for the following requirements

Hi Support

Hope you are doing well.

I have a requirement which is like that.

We have certain html pages developed using HTML5, CSS3, High charts and Jquery.

Some buttons have been placed over there on html like as follows.

  • Export to pdf
  • . Export to word
  • . Export to excel.

Using these button the page can be exported to pdf, word and excel as it is.

Can you suggest me any product of yours’s which will meet this criteria .

Any help would be highly appreciated . waiting
for your prompt reply in this regard

Hi Ghazi,


Thanks for contacting support.

We have an API named Aspose.Pdf for .NET which provides the feature to read HTML along with CSS and create output in PDF, MS Word or Excel format. But I am afraid the API may not be able to execute the JQuery during conversion. For further details, please visit


PS, once you have read the HTML file, use different values from SaveFormat enumeration to save the output in different formats.

I could not get this piece of code

string dataDir= RunExamples.GetDataDir_AsposePdf_DocumentConversion();
Not able to find RunExamples … where it is??

Dear Support

i have taken this code for pdf from your site.

string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();

HtmlLoadOptions options = new HtmlLoadOptions();
options.CustomLoaderOfExternalResources = new LoadOptions.ResourceLoadingStrategy(SamePictureLoader);

Document pdfDocument = new Document(dataDir + “HTMLToPDF.html”, options);
pdfDocument.Save(“HTMLToPDF_out.pdf”);

But where to find RunExamples and SamePictureLoader ??
Please help . This is RunExamples is there in each demo code

Regards
Ghazi

is it possible to directly download it in browser instead of saving it in a folder.

if possible can you share me this code
Ghazi786:
I could not get this piece of code
string dataDir= RunExamples.GetDataDir_AsposePdf_DocumentConversion();
Not able to find RunExamples .. where it is??

Hi Ghazi,

Thanks for contacting support.

Its the baseparth where HTML file is located. You can pass your system directory where input files are located.

Hi Ghazi,

The argument for ResourceLoadingStrategy is used when we need to specify some mechanism for external resources (i.e. Images, CSS etc) referenced inside HTML file. Please note that Sometimes it’s necessary to avoid usage of internal loader of external resources(like images or CSS) and supply custom method, that will get requested resources from somewhere. For example, during usage of Aspose.Pdf in cloud, direct access to referenced files may not be possible. Therefore this delegate defines signature of such custom method.

However you may try using following simple code snippet to perform HTML to PDF conversion without getting into extra technical details (as a quick start).

[C#]

// instantiate HTMLLoadOptions object

HtmlLoadOptions options = new HtmlLoadOptions();

// options.CustomLoaderOfExternalResources = new LoadOptions.ResourceLoadingStrategy(SamePictureLoader);

// load HTML file contents into Document instance

Document pdfDocument = new Document(dataDir + "HTMLToPDF.html", options);

// save resultant PDF file

pdfDocument.Save("HTMLToPDF_out.pdf");

Thanks i have tried that code . it is working fine now.

But the generated PDF does not contain any Highcharts. It does not process the Jquery code which is responsible for generating the charts.
Please check and let me know .

Hi Ghazi,

Thanks for sharing the details.

Do you mean rendering the resultant PDF file into browser ?

If so is the case, then you can save the output in Stream object and then pass the stream contents to Response object.

[C#]

// instantiate HTMLLoadOptions object

Aspose.Pdf.HtmlLoadOptions options = new Aspose.Pdf.HtmlLoadOptions();

// options.CustomLoaderOfExternalResources = new LoadOptions.ResourceLoadingStrategy(SamePictureLoader);

// load HTML file contents into Document instance

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("c:/pdftest/input.html", options);

// SaveOptions instance

Aspose.Pdf.SaveOptions save = new Aspose.Pdf.PdfSaveOptions();

save.CloseResponse = true;

// render output in Browser Response.

pdfDocument.Save(Response,“Resultant.pdf”, Aspose.Pdf.ContentDisposition.Inline,save);
Ghazi786:
Thanks i have tried that code . it is working fine now.
But the generated PDF does not contain any Highcharts. It does not process the Jquery code which is responsible for generating the charts.
Please check and let me know .
Hi Ghazi,

Thanks for sharing the details.

Can you please share the input HTML and any related resource files, so that we can test the conversion in our environment. We are sorry for this inconvenience.

Hi Support

Please find below the html file i am trying to convert to pdf.

https://cmm.buoyant.dk/StatisticsReport.html

Regards

Ghazi Anwer

Hi Ghazi,

Thanks for sharing more details.

I have tested the scenario in my environment using following code snippet and observed the issue. The generated output had missing content and layout was disturbed. Therefore, I have logged an issue as PDFNET-42564 in our issue tracking system for the purpose of detailed investigation. We will further look into this and keep you informed on the status of its correction. Please be patient and spare us a little time.

System.Net.WebRequest request = System.Net.WebRequest.Create(“https://cmm.buoyant.dk/StatisticsReport.html”);<o:p></o:p>

request.Credentials = System.Net.CredentialCache.DefaultCredentials;

request.Timeout = 5000;

System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();

Stream dataStream = response.GetResponseStream();

StreamReader reader = new StreamReader(dataStream);

string responseFromServer = reader.ReadToEnd();

reader.Close();

dataStream.Close();

response.Close();

MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseFromServer));

HtmlLoadOptions options = new HtmlLoadOptions("https://cmm.buoyant.dk/");

options.ExternalResourcesCredentials = System.Net.CredentialCache.DefaultCredentials;

Document pdfDocument = new Document(stream, options);

pdfDocument.Save(dataDir + @"Html2PDF_out.pdf");

I have also attached generated output by above code for your reference. We are sorry for the inconvenience.

Best Regards,

Dear Asad

Any update on this.
I am waiting for the solution so that i can embed it into my application.
Please reply

Regards
Ghazi Anwer

Hi Support

I have tried saving a pdf document as a doc format but it is not converting it properly.
I am using aspose.pdf for .net for this purpose .
it’s left the some portion to be converted into the doc.
I am attaching both the pdf and the resultant doc file for your reference .
Find below the code i have used this purpose.

====================
string dataDir = “D:/BackUp/”;

// Open the source PDF document
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(dataDir + “Report.pdf”);

// for browser
MemoryStream stream = new MemoryStream();
pdfDocument.Save(stream, SaveFormat.Doc);
Response.Clear();
//Specify the document type.
Response.ContentType = “application/doc”;
Response.AddHeader(“content-disposition”, “inline; filename=Report.doc”);
byte[] bytes = stream.GetBuffer();
Response.BinaryWrite(bytes);
Response.End();
======================

Hi Ghazi,

Thanks for your patience.

I am afraid the earlier reported issue is still pending for review and is not yet resolved. However as soon as we have some definite updates regarding its resolution, we will let you know.

Hello Ghazi,


Thanks for your inquiry.

ganwer-proind_in:
I have tried saving a pdf document as a doc format but it is not converting it properly.
I am using aspose.pdf for .net for this purpose .
it’s left the some portion to be converted into the doc.

I have checked the document(s) which you have shared and noticed that the Word Document (Report.doc) had Evaluation Warning inside it, which means that it was created by using evaluation version of the API. Please note that with evaluation mode of license, you can only process up to 4 elements in a collection. That is why the Word Document had only 4 pages and rest pages from PDF document were skipped.

Furthermore, if you have purchased version/license of the API then it is quite possible that license was not set properly before performing the conversion operation. For information regarding setting license, you may visit Licensing in API documentation.

I have converted your document with a valid license and the output was fine. I am attaching the output/converted document for your reference as well. In case of any further assistance, please feel free to contact us.


Best Regards,

Hi

Ok it is fine .
I have one more problem. while saving the pdf to excel i gets the following error.
"Unsupported options for saving pdf on web"
Please find below the code i have written for the same.

====
string dataDir = “D:/BackUp/”;

// Open the source PDF document
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(dataDir + “Report.pdf”);

//new code
Aspose.Pdf.ExcelSaveOptions save = new Aspose.Pdf.ExcelSaveOptions();
save.CloseResponse = true;
// render output in Browser Response.
pdfDocument.Save(Response, “Report.xls”, Aspose.Pdf.ContentDisposition.Inline, save);
================
I gets this error on the following line.

pdfDocument.Save(Response, “Report.xls”, Aspose.Pdf.ContentDisposition.Inline, save);

Hi Ghazi,

Thanks for your inquiry.

Please check following code snippet, in order to save converted file on server using HttpResponse.

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(Server.MapPath(@“App_Data/Report.pdf”));
Aspose.Pdf.ExcelSaveOptions save = new Aspose.Pdf.ExcelSaveOptions();
save.CloseResponse = true;
MemoryStream stream = new MemoryStream();
pdfDocument.Save(stream, save);
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.Charset = "UTF-8";
Response.AddHeader("Content-Length", stream.Length.ToString());
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "ConvertedFile.xls"));
Response.ContentType = "application/excel";
Response.BinaryWrite(stream.ToArray());
Response.Flush();
Response.End();

In case of any further assistance, please feel free to contact us.

Best Regards,

Hi support

I have tried the code accordingly But i got the blank excel.
Please see both the file attached.

===code is given below=======
string dataDir = “D:/BackUp/”;
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(dataDir + “Report.pdf”);
Aspose.Pdf.ExcelSaveOptions save = new Aspose.Pdf.ExcelSaveOptions();
save.CloseResponse = true;
MemoryStream streams = new MemoryStream();
pdfDocument.Save(streams, save);
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.Charset = “UTF-8”;
Response.AddHeader(“Content-Length”, streams.Length.ToString());
Response.AddHeader(“content-disposition”, String.Format(“attachment;filename={0}”, “ConvertedFile.xls”));
Response.ContentType = “application/excel”;
Response.BinaryWrite(streams.ToArray());
Response.Flush();
Response.End();


Hi Ghazi,


Thanks for contacting support.

I have tested the resource file(s) and observed that the XLS file had Evaluation Warning inside it which mean it was converted using evaluation version of API or without setting the license properly. I have managed to produce the valid output by using same input document and code snippet which was shared above.

I have attached generated output for your reference as well and please try the conversion process after setting the license properly. For more information regarding setting license, please visit Licensing article in our API documentation.

In case of any further inquiry, please feel free to ask.


Best Regards,