Nayyer Shahbaz August 26, 2015one Comment

Strikeout Text, addition of HTML to existing PDF, determine PDF/A file and an optimized inter file format conversion with Aspose.Pdf for .NET 10.7.0

Strikeout Text, addition of HTML to existing PDF, determine PDF/A file and an optimized inter file format conversion with Aspose.Pdf for .NET 10.7.0

August 26, 2015
Share on FacebookTweet about this on TwitterShare on LinkedIn

Aspose.Pdf for .NET logoA new release of Aspose.Pdf for .NET 10.7.0 has been published with new features and enhancements which were requested in earlier release versions. Likewise previous versions, this new release also contains fixes for issues reported against previous releases. Following are some details regarding features introduced in this new release.

Strikeout feature in TextState class

The TextState class provides the capabilities to set formatting for TextFragments being placed inside PDF document. You can use this class to set text formatting as Bold, Italic, Underline and starting this release, the API has provided the capabilities to mark text formatting as Strikeout. Please try using following code snippet to add TextFragment with Strikeout formatting. Meanwhile you may consider visiting following link for further details on Add Text in existing PDF file

//open document
Document pdfDocument = new Document();
//get particular page
Page pdfPage = (Page)pdfDocument.Pages.Add();

//create text fragment
TextFragment textFragment = new TextFragment("main text");
textFragment.Position = new Position(100, 600);

//set text properties
textFragment.TextState.FontSize = 12;
textFragment.TextState.Font = FontRepository.FindFont("TimesNewRoman");
textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.LightGray;
textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Red;
//set StrikeOut property
textFragment.TextState.StrikeOut = true;
// mark text as Bold
textFragment.TextState.FontStyle = FontStyles.Bold;

// create TextBuilder object
TextBuilder textBuilder = new TextBuilder(pdfPage);
// append the text fragment to the PDF page
//save document

Add HTML contents to existing PDF document

Aspose.Pdf for .NET provides the capabilities to Convert HTML to PDF Format, as well as the feature to Add Text in an Existing PDF File. However with this release, we have also introduced the feature to add HTML contents inside PDF document where HTML tags will be rendered accordingly, instead they appear as static HTML tags.

//open document
Document pdfDocument = new Document();
string outFile = "33851.pdf";
// create HTML Fragment object to speicfy the HTML contents which need to be added
HtmlFragment t = new HtmlFragment(" < body style='line-height: 100px;'>First line of text
Second Line of Text
  • First
  • Second
  • Third
  • Fourth
  • Fifth
Text after the list.
Next line
Last line "); // add page to pages collection of Document instance Page page = pdfDocument.Pages.Add(); // add HTML fragment to paragraphs collection of page page.Paragraphs.Add(t); // save output file pdfDocument.Save(outFile);

Determine of document is PDF/A file

Aspose.Pdf for .NET provides the feature to convert PDF file to PDF/A fomat, convert PDF/A file to PDF format and the feature to Validate if PDF document is PDF/A compliant. It also offers the capabilities to determine if loaded document is a valid PDF and also if its encrypted or not. In order to further extend the capabilities of Document class, IsPdfaCompliant property is added to determine if input file is PDF/A compliant and a property named PdfaFormat to identify the PDF/A format are introduced.

Footnote enhancement in DOM approach

In earlier release versions, the Footnote support has been provided but it was only applicable to TextFragment object. However now you can also add Footnote to other objects inside PDF document such as Table, Cells etc. The following code snippet shows the steps to add Footnote to TextFragment object and then add table to paragraphs collection of Footnote section.

string outXml = TestSettings.GetOutputFile("38614.xml");
string inFile = TestSettings.GetInputFile("..//new_Logo.bmp");
string outFile = TestSettings.GetOutputFile("38614.pdf");
Document doc = new Document();
Page page = doc.Pages.Add();
TextFragment text = new TextFragment("some text");
Aspose.Pdf.Image image = new Aspose.Pdf.Image();
image.File = inFile;
image.FixHeight = 20;

text.FootNote = new Note();
TextFragment footNote = new TextFragment("footnote text");
footNote.TextState.FontSize = 20;
footNote.IsInLineParagraph = true;
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
table.Rows.Add().Cells.Add().Paragraphs.Add(new TextFragment("Row 1 Cell 1"));
doc = new Document();

TabStops for Text objects using DOM

A Tab Stop is a stop point for tabbing. In word processing, each line contains a number of tab stops placed at regular intervals (for example, every half inch). They can be changed, however, as most word processors allow you to set tab stops wherever you want. When you press the Tab key, the cursor or insertion point jumps to the next tab stop, which itself is invisible. Although tab stops do not exist in the text file, the word processor keeps track of them so that it can react correctly to the Tab key. For further details, please visit Working with Custom Tab stops

Document _pdfdocument = new Document();
Page page = _pdfdocument.Pages.Add();

Aspose.Pdf.Text.TabStops ts = new Aspose.Pdf.Text.TabStops();
Aspose.Pdf.Text.TabStop ts1 = ts.Add(100);
ts1.AlignmentType = TabAlignmentType.Right;
ts1.LeaderType = TabLeaderType.Solid;
Aspose.Pdf.Text.TabStop ts2 = ts.Add(200);
ts2.AlignmentType = TabAlignmentType.Center;
ts2.LeaderType = TabLeaderType.Dash;
Aspose.Pdf.Text.TabStop ts3 = ts.Add(300);
ts3.AlignmentType = TabAlignmentType.Left;
ts3.LeaderType = TabLeaderType.Dot;

TextFragment header = new TextFragment("This is a example of forming table with TAB stops", ts);
TextFragment text0 = new TextFragment("#$TABHead1 #$TABHead2 #$TABHead3", ts);
text0.TextState.FontStyle = FontStyles.Bold;
TextFragment text1 = new TextFragment("#$TABdata11 #$TABdata12 #$TABdata13", ts);
TextFragment text2 = new TextFragment("#$TABdata21 ", ts);
text2.Segments.Add(new TextSegment("#$TAB"));
text2.Segments.Add(new TextSegment("data22 "));
text2.Segments.Add(new TextSegment("#$TAB"));
text2.Segments.Add(new TextSegment("data23"));



Miscellaneous fixes

As well as the enhancements and features discussed above, there have been specific improvement for PDF to HTML and HTML to PDF conversion features with better support for HTML5. Among these fixes, the PCL to PDF, SVG to PDF, PDF to Excel, PDF to DOC, PDF to TIFF and TIFF to PDF conversion, conversion of PDF to PDF/A compliant documents, text replacement, Filling of signature field with an image, flattening of PDF and rendering of PDF to XPS format, FloatingBox rendering, Footnote, EndNote and rendering of non-English (specifically Arabic) contents are also improved. Please download and try the latest release of Aspose.Pdf for .NET 10.7.0.

Join the Conversation

1 Comment

Leave a comment

Posted inAspose.PDF Product Family, Nayyer Shahbaz

Related Articles