Rendering Documents as PDF

Share on FacebookTweet about this on TwitterShare on LinkedIn

The Portable Document Format (PDF) is a file format to present documents, including text formatting and images, in a manner independent of the application software, hardware, and operating systems. Based on the PostScript language, each PDF file encapsulates a complete description of a fixed-layout flat document, including the text, fonts, vector graphics, raster images and other information needed to display it.

This post demonstrates the usage of the GroupDocs.Viewer APIs (GroupDocs.Viewer for .NET and GroupDocs.Viewer for Java) to render the supported file formats as PDF documents.

How to Render Using GroupDocs.Viewer

Both the viewer handlers (ViewerHtmlHandler,ViewerImageHandler) provide an overloaded method GetPdfFile() which accepts the document name as parameter and returns FileContainer. The File stream can be fetched from the Stream property of the FileContainer in order to save the resultant document on the disk.

The following code snippet shows the way to render a word document as PDF:

Java lovers can write the code like following:

Add Print Action while Rendering as PDF

A Print Action is an option to appear the print popup when open the PDF document in Adobe reader. The popup will appear like below screenshot:

The below given steps can be followed, in order to add print action in the resultant PDF document.

  • Create/initialize PdfFileOptions object
  • Set Transformations property of PdfFileOptions to Transformation.AddPrintAction
  • Call htmlHandler.GetPdfFile method

The .NET code snippet will look like:

The Java code can be written as:

The complete ready to run code sample is available on GitHub.

  • The .NET guys can visit here
  • The code sample for Java lovers is available here

The post Rendering Documents as PDF appeared first on Document Manipulation APIs Blog –

Posted in Conholdate.Total Product Family, GroupDocs.Viewer Product Family | Tagged | Leave a comment

Identify Style Separator Paragraph, Get Font Line Spacing, Fake Result of Field, and Load Fonts from Stream

Share on FacebookTweet about this on TwitterShare on LinkedIn

Hi guys! We are pleased to announce the new release of Aspose.Words for .NET 19.5. After reading this blog, you will be able to work with paragraph style separator, smart style behavior while joining documents, line spacing of font, get the field’s result that has no field separator node, load fonts from stream, and DML text effect. Interesting, isn’t it?

Let’s check out these features one by one.

Added Overload of AppendDocument Method With Additional ImportFormatOptions Parameter

We added ImportFormatOptions.SmartStyleBehavior property in Aspose.Words 19.4 to specify how styles will be imported while importing one document into another. In this release, we added overload of Document.AppendDocument method that uses this property while joining documents. The additional options will affect the formatting of result document. Here is a simple code example for you.

Identify Style Separator Paragraph

The style separator can be added to the end of a paragraph using the Ctrl + Alt + Enter Keyboard Shortcut into MS Word. This feature allows for two different paragraph styles used in one logical printed paragraph. Starting from Aspose.Words 19.5, you will be able to identify either paragraph break is a Style Separator or not. The Paragraph.BreakIsStyleSeparator property has been added in this release. Below code example shows how to use it.

How to Get Font Line Spacing

In typography, leading (line spacing of a font) refers to the distance between adjacent lines of type. It is the vertical distance between the baselines of two consecutive lines of text. Thus, the line spacing includes the blank space between lines along with the height of the character itself.

The solution to get the font line space is simple. It is Font.LineSpacing property that has been added in this release. Please check the following code example.

Obtain Fake Result of Field

Starting from Aspose.Words 19.5, you can get the result of field that has no field separator node. We added Field.DisplayResult property to achieve it. Note that MS Word displays it in the document by calculating the field’s value on the fly. You can use this property as shown below.

Add feature to Load Fonts from Stream

In some cases, you need to load fonts from stream instead of disk. Now, you do not need to worry about it. We added new feature in this release to load the fonts from stream that will be used during Document import and rendering document to fixed file formats. Please refer to the following article for more detail.
Loading Fonts from Stream

How to Check DML Text Effect

MS Word allows user to set the text effect e.g. Glow, Fill, Shadow etc. To get this text effect, we added Font.HasDmlEffect method in this release. Below code example shows how to use it.

Obsolete Properties and Methods Related to Font Substitution Settings were Removed from FontSettings class

You may be wondering about deleted API. Here is the detail of deleted properties and methods.

Obsolete property DefaultFontName was removed from FontSettings class. Please use SubstitutionSettings.DefaultFontSubstitution instead.

Obsolete property EnableFontSubstitution was removed from FontSettings class. Please use SubstitutionSettings.FontInfoSubstitution instead.

Obsolete methods GetFontSubstitutes, SetFontSubstitutes, AddFontSubstitutes was removed from FontSettings class. Please use SubstitutionSettings.TableSubstitution instead.

There are many other features, enhancement, and bug fixes included in this release. Please check the release notes of Aspose.Words for .NET 19.5.

When time allows you can check Aspose.Words’ API examples at Github, talk about this release and other API related issues in our forum.

Posted in Conholdate.Total Product Family, Aspose.Words Product Family | Tagged | Leave a comment

Support for encoding MPX files available in Aspose.Tasks 19.4

Share on FacebookTweet about this on TwitterShare on LinkedIn

aspose-tasks-for-netHi friends! In today’s blog, I will be giving you tour of latest Aspose.Tasks 19.4. The commendable thing about Aspose team is that it publishes both .NET and Java based API for Aspose.Tasks simultaneously every month. Both .NET and Java based variants are at same level in terms of features and both API users may explore the new features in their respective environments. In following section, I will be discussing about new features and improvement carried in API.

Encoding Microsoft Project File Exchange (MPX) Files

MPX is a ASCII coded text based file format used by Microsoft Project. It’s mainly used for transferring project data between different versions of Project. These files can also be opened by some project planning programs, such as Primavera Project Planner etc.

With this new support available, one can also import data from Primavera MPX file format too. In following example, you may observe a scenario importing data from Primavera MPX file format.

The similar Java based implementation for the same is like as under:

Rendering Improvements

In this release the focus has also been set on improvement of rendering performance of API. For that matter, limitations like missing header footer information, improper Gantt chart colors in rendered images or PDFs have also been addressed

Hold on, there’s many other features, enhancement, and bug fixes included in this release. Here you can get the detail!

We have also maintained the working sample examples for both .NET and Java based APIs on Github so that users may right away use different samples and explore API features. You may also talk about API related issues with us in our product support forum.

Posted in Conholdate.Total Product Family, Aspose.Tasks Product Family | Tagged | Leave a comment

Release JAR Upgraded to JDK 7, Add Bi-Directional Marks in TXT and much more by using Aspose.Words for Java 19.3

Share on FacebookTweet about this on TwitterShare on LinkedIn

Guys, lets check out what’s new for you in Aspose.Words for Java 19.3 release.

Release JAR Upgraded to JDK 7

We have upgraded the release JAR of Aspose.Words for Java from JDK 6 to JDK 7. This means that if you are referencing Aspose.Words for Java from Maven then you will have to update the classifier value to jdk17 as follows:


Preserve Representation of Legacy Control Characters While Exporting Document to OOXML

Some document formats support legacy control characters. MS Word does not save these symbols to DOCX format (more accurately in OOXML formats). However, we added new property KeepLegacyControlChars in OoxmlSaveOptions class to preserve such control characters. So far only one legacy character (ShortDateTime) is supported which declared in the “DOC” format. Here’s how you can use this property:

How to Add Bi-Directional Marks

You can use TxtSaveOptions.AddBidiMarks property to specify whether to add bi-directional marks before each BiDi run when exporting in plain text format. Aspose.Words inserts Unicode Character ‘RIGHT-TO-LEFT MARK’ (U+200F) before each bi-directional Run in text. This option corresponds to “Add bi-directional marks” option in MS Word File Conversion dialog when you export to a Plain Text format. Note that it appears in dialog only if any of Arabic or Hebrew editing languages are added in MS Word. Below code example shows how to use TxtSaveOptions.AddBidiMarks property. The default value of this property is false.

Predefined Font Fallback Settings for Google Noto Fonts

You may know about Noto. It is a font family comprising over a hundred individual fonts. We have added predefined font fallback settings for Google Noto fonts. These are free fonts licensed under SIL OFL. Here are two important points:

  • The predefined settings uses only Sans style Noto fonts with regular weight.
  • Aspose.Words does not support advanced typography. So, the Noto fonts that use advanced typography may be rendered inaccurately

Following code example shows how to use predefined font fallback settings

Text Alignment of Axis Tick Labels

If you want to set text alignment for multi-line labels, you can simply achieve this by setting the value of ChartAxis.setTickLabelAlignment() property. Following code example shows how to tick label alignment.

Specify How List Levels are Indented When Exporting Document to Plain Text Format

Aspose.Words introduced TxtListIndentation class that allows specifying how list levels are indented while exporting to a plain text format. While working with TxtSaveOption, the ListIndentation property is provided to specify the character to be used for indenting list levels and count specifying how many characters to use as indentation per one list level. The default value for character property is ‘{$content}’ indicating that there is no indentation. For count property, the default value is 0 which means no indentation.

Using Tab Character

Using Space Character

Using Default Indentation

See also Useful Links

Keeping the Aspose tradition, you are welcome to shape the upcoming releases of Aspose.Words for Java API by posting your suggestions and concerns in the Aspose.Words for Java Support Forum.

Posted in Conholdate.Total Product Family, Aspose.Words Product Family | Tagged | Leave a comment