Embed Media Files in PDF File and HTML Text Formatting Support in Aspose.Pdf for .NET 17.3.0

We are pleased to announce new release Aspose.Pdf for .NET 17.3.0. This month release includes new feature to calculate Table width and embed media files(audio and video) in PDF document along with some other important features. We have also enhanced Footnote feature and HTML text support in this version in addition to many other bug fixes reported in old releases that improves the APIs functionality. Please check the detailed release notes of this version to get an idea about the new features/enhancements and fixes made in this release.

Furthermore, If you are planning to upgrade the API from any previous version, we strongly recommend you to check the Public API Changes section of other intermediate releases from release notes folder, to know what has been changed since your current revision of the API.

The following sections describe some details regarding these newly added enhancements.

Embed Media files in PDF Document

We have implemented a new annotation RichMediaAnnotation in Aspose.Pdf for .NET 17.3.0. It is used to embed media files within PDF document. In fact RichMediaAnnotation is container for SWF (Flash) script. Due to license restriction we cannot include third-party flash scripts in our product, so you should provide your own script for playing video or audio. For example you can use VideoPlayer and AudioPlayer shipped with Adobe Acrobat. Please check documentation link for sample code and details to embed video/audio files in PDF document using RichMediaAnnotation.

Calculate Table Width

In some scenarios, you have not hard coded the Table width in PDF document and later you want to know its width for some post processing. We have introduced a new method GetWidth() to calculate Table width in this release. It renders the table and gets its width as following:

Aspose.Pdf.Table table = new Aspose.Pdf.Table();
table.ColumnAdjustment = ColumnAdjustment.AutoFitToContent;
Aspose.Pdf.Row row = table.Rows.Add();
Aspose.Pdf.Cell cell1 = row.Cells.Add("Cell 1");
Aspose.Pdf.Cell cell2 = row.Cells.Add("Cell 2 text");
// get Table width
// get cell width

HTML Text Formatting

Aspose.Pdf supports insertion of HTML string in PDF document. If HTML specified fonts are available on host system then it uses same fonts, otherwise it uses system default fonts for HTML string. We have received some requirements to support font overriding feature for HTML string. We have implemented TextState object in HtmlFramgent class, now you can override font details of HTML string as following:

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Page page = doc.Pages.Add();
HtmlFragment html = new HtmlFragment("some text");
html.TextState = new TextState();
html.TextState.Font = FontRepository.FindFont("Calibri");

FootNote Color

In current release, we have also added support to set color of FootNote label(node identifier). We have implemented TextState object in FootNote class. You can set FootNote label color using TextState as following:

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Page page = doc.Pages.Add();
Aspose.Pdf.GraphInfo graph = new Aspose.Pdf.GraphInfo();
graph.LineWidth = 2;
graph.Color = Aspose.Pdf.Color.Red;
graph.DashArray = new int[] { 3 };
graph.DashPhase = 1;
page.NoteLineStyle = graph;
TextFragment text = new TextFragment("test text 1");
text.FootNote = new Note("foot note for test text 1");
text.FootNote.Text = "21";
text.FootNote.TextState = new TextState();
text.FootNote.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
text.FootNote.TextState.FontStyle = FontStyles.Italic;
doc.Save(myDir + "footnote.pdf");

Aspose.Pdf for .NET Resources

The following resources will help you work with Aspose.Pdf for .NET:

To keep up with our news, you can follow us on Twitter or follow our Facebook page.

Leave a Reply