Returning a non-PDF file from HTML

I am able to get the .Save() to work just fine, and the PDF looks great.

However, I am only looking to convert a string of HTML, and not an entire page. Again, I can get this to work and save into a PDF document.

What I need it to do is take the HTML string, and append its PDF equivalent to a PDF doc I am creating using iTextSharp.


PDF stuff
HTML converted to PDF
PDF stuff
New Page
More HTML converted to PDF

So basically, instead of saving to a new file, I just want to have a string of HMTL convereted to a PDF Section or Chunk that I can then add to a PDF I am creating on the fly.

Thanks in advance!


Hello Mike,

Thanks for using our products.

I am pleased to inform you that Aspose.Pdf for .NET also supports the feature to convert a single HTML string into PDF format. For more information, please visit HTML Tags in Text

However the feature of adding HTML string to an existing PDF document is currently not supported. For the sake of correction, I have logged it as PDFNEWNET-29902 in our issue tracking system. We will further look into the details of this requirement and will keep you updated on the status of correction. We apologize for your inconvenience.

Thank you for the response.

I do have another question.

Say I have a pdf object that I put some content into such as HTML in the form of a text -> section -> pdf

Is there any way to render that back into an object rather than to a pdf file?

The idea is to accomplish the same as the original question, only to have it saved to an object I can use elsewhere rather than straight to a file.



Hello Mike,

Thanks for your patience.

From your query, do you need to read the resultant PDF (after adding Text segment to it) or you need to get hold of Text object added to paragraphs collection of the Section object.

FYI, Beside saving the resultant PDF over system, Aspose.Pdf for .NET also provides you the capability to save the document into Stream object. Please visit public void Save(Stream);

We use itextSharp for pdf creation with various user data.

Some of the data we have is in HMTL format, and we’ve had a hard time getting tables and lists to render correctly, even through our own conversion routines.

So, we wanted to use Aspose.pdf to produce a correctly rendered PDF chunk from HTML to insert into our document being generated through itextsharp.

We do not currently stream this particular document because the user wants hard copies available on the server at all times. However, we do use itextsharp to render a pdf back as a memory stream to the user.

We also had the thought of just rendering our document (usually 1-2 pages) as a HTML chunk that Aspose then PDFs.

Either way, I think we can have a workable solution for our customer.


Hello Mike,

Thanks for sharing the details. Let me rephrase what I have understood from your previous post.

You are trying to render HTML file into PDF format using Aspose.Pdf for .NET and finally you need to concatenate/merge this document to your original PDF being generated through itextsharp.

While using Aspose.Pdf for .NET, you get the option to save the resultant PDF over system or you can render the resultant PDF to Response object (display the PDF in user’s browser). In case you are facing issues while merging the PDF document generated with Aspose.Pdf for .NET and the document being generated with itextsharp, you may think of using following workaround.

  1. Convert HTML files into PDF format using Aspose.Pdf for .NET
  2. Generate PDF document using itextsharp.
  3. Merge/concatenate all the documents into single resultant PDF using Aspose.Pdf for .NET. Please visit the following links for information on
In case still I have not properly understood your requirement, please share some more details.

That is very close to what we are trying to do.

However, we do not want to append the entire page of the render from Aspose.

Say an HTML render is only a simple table that takes up a small part of the page. We only want to take the table and insert it into an existing PDF we are generating. We do not want the entire page that is generated. This partial page is then appended to our PDF, and we then continue our own processing.

I hope this make a little more sense. I’m not very articulate about things, so painting a picture is a work in progress for me.

Thanks again for any insight you can give me.


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

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