How to set HtmlSaveOptions to save html and resources to stream

Hi everyone!

We are trying to use Aspose.PDF to load PDF from databases, convert it to HTML and render them to our web page. We want to if we can save both the document and the resource to stream since current example in the document of Aspose.PDF saves css and images to a local path. If it can be done, how to write the parameters of CustomResourceSavingStrategy, CustomCssSavingStrategy, and CustomStrategyOfCssUrlCreation.


Hi Rui,

Thanks for contacting support.

Since your requirement is to display PDF files, I would suggest you to try using ViewerApp of our sister company named GroupDocs and you won’t have to be worried about conversion and resource saving in Stream objects.

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

Hi Nayyer,

Thanks for recommendation of GroupDocs. Actually we have used that before ans it is really a good and handy product that includes everything necessary for a viewer. However, as we want to have more customization, we try to build our own version. Thanks!

Hi Rui,

Thanks for sharing the details.

We are working on preparing the required code snippet and will get back to you soon.

Hi Rui,

I have further discussed the requirement with development team and in order to implement full saving of all output (main HTML and related resources) into one target stream, it’s necessary to do some additional work inside Aspose.Pdf and/or use Asp.Net components to implement embedding of all output files (images, fonts,CSSes) in one output HTML. Currently we are not entirely certain that this feature can be implemented but for the sake of further investigation, I have logged this task as PDFNEWNET-37135 in our issue tracking system. The development team will further look into the details of this requirement and we will keep you posted on the status of correction. Please be patient and spare us little time.

Hi codewarior is not online. Last active: Jun 30, 2014, 7:18 AM Nayyer,

Thank you so much for logging my problem and I look forward to get feedback from your develop team. Besides my previous question, I was wondering if I can save html codes generated from PDF in the format of separated pages and if there is an option like ResourceSavingInfo or CssSavingInfo to configure that operation. Thanks!

Hi Gary,

Thanks for sharing the feedback. As per my understanding, you need to split the resultant HTML into pages rather than displaying the output as single HTML file. If so is the case, then I am pleased to share that Aspose.Pdf for .NET supports this feature. For more information, please visit PDF to HTML - Split CSS to pages and try using following code snippet.


Document doc = new

HtmlSaveOptions newOptions = new HtmlSaveOptions();

newOptions.SplitIntoPages = true;

doc.Save(TestSettings.GetOutputFile(“35597.html”), newOptions);

In case I have not properly understood your requirement, please share some further details.

Hi Nayyer,

I am sorry that I didn’t clarify my question. I was hope if there is a function that can save splited html pages into stream like what I did in saving resources file of a page by configuring the saveoption like that :

public class ResourceFile
public string FileName { get; set; }
public MemoryStream FileContent { get; set; }
public ResourceFile(string FileName, MemoryStream FileContent)
this.FileName = FileName;
this.FileContent = FileContent;
private List ResourceFileList { get; set; }

private string CustomResourcesProcessing(SaveOptions.ResourceSavingInfo resourceSavingInfo)
MemoryStream newResource = new MemoryStream();
ResourceFile file = new ResourceFile(resourceSavingInfo.SupposedFileName,newResource);

string urlThatWillBeUsedInHtml = RequestURL + “/” + Path.GetFileName(resourceSavingInfo.SupposedFileName);
return urlThatWillBeUsedInHtml;

Thus I got a list of resources whose content are saved in MemoryStream so that I can store them in our library. We don’t want save any temporary files in our disk so we store the components of the HTML converting result in BOLB format. Currently We got that exception “Inconsistent saving options detected : ‘SplitIntoPages’ may not be ‘true’ when requested saving to stream!”. I was wondering if we can save split pages to stream. Thanks!

Hi Gary,

Thanks for sharing the details and sorry for the delayed response.

As per my understanding, you need the feature to split the resultant HTML to pages and save individual page output to Stream object and all corresponding resources of individual page should also be saved in Stream object. The intents is that you can get the output in Stream object and then save it as BLOB in database.

Please acknowledge so we may proceed further.

Hi Nayyer,

Yes! That’s the feature I am looking for! Thank you so much for you support!

Hi Gary,

Thanks for the acknowledgement.

The information has been shared with development team and they will definitely consider this requirement during the implementation of PDFNEWNET-37135. As soon as we have some further updates, we will let you know.

The issues you have found earlier (filed as PDFNEWNET-37135;PDFNEWNET-37135) have been fixed in Aspose.Pdf for .NET 9.5.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Gary,

Thanks for your patience. You reported issue has been fixed. Please check following documentation link to save Html and resources in stream object. It will help you to accomplish the task.

Please feel free to contact us for any further assistance.

Best regards,