Rotate Text in Table Cell

Aspose PDF .NET 10.4


Using the DOM (not generator), how do I rotate text within a table cell?

Hi Dirk,

Thanks for using our API’s.

I am afraid currently the DOM approach does not support the feature to rotate text inside Table cell. However PDFNEWNET-38835 has been logged for this required functionality. We will try to figure the feasibility and will keep you updated on the status of this implementation.
Please be patient and provide us with some time. We are sorry for this inconvenience.

Bummer.


Do you have any other work arounds?

Could I create a SVG in memory with the text and rotate that and insert it into the PDF?

Could I create another type of Aspose object, rotate it, and then place it in the cell?

Can I mix in the generator and create a piece that I can insert into the DOM table cell?

Should I even be using the DOM api? It seems like I keep running into things that are in the Generator but are not in the DOM api. I thought the Generator was deprecated??

dirq: Do you have any other workarounds?

Could I create an SVG in memory with the text and rotate that and insert it into the PDF?

Hi Dirk,

Yes, as a workaround, you can create an SVG with text and instantiate an HtmlFragment instance and place it inside the paragraph collection of a table cell. Please take a look at the following code snippet.

[C#]

Aspose.Pdf.HtmlFragment html = new HtmlFragment(
    "<svg height=\"20\" width=\"20\"> <text x=\"10\" y=\"5\" fill=\"black\" transform=\"rotate(30 20,40)\">header-\" + hc+\"</text> </svg>"
);
html.IsInLineParagraph = true;
cell.Paragraphs.Add(html);

dirq: Could I create another type of Aspose object, rotate it, and then place it in the cell?

HtmlFragment can be a solution in the current circumstances.

dirq: Can I mix in the generator and create a piece that I can insert into the DOM table cell?

I am afraid you cannot use objects from different namespaces in a single application cycle. However, you can individually use objects from each namespace. For example, create a PDF file using Aspose.Pdf.Generator, save the output in a Stream instance, and then manipulate the PDF file using the DOM approach.

dirq:
Should I even be using the DOM api? It seems like I keep running into things that are in the Generator but are not in the DOM api. I thought the Generator was deprecated??
Hi Dirk,

The new DOM model of Aspose.Pdf namespace is recommended approach and we always recommend our customers to try migrating to this new model as it includes all new enhancements and new features. However we are gradually adding missing features in this new model.

The issues you have found earlier (filed as PDFNET-38835) have been fixed in Aspose.Pdf for .NET 17.6.


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

Hi Dirk,


Thanks for your patience.

In order to resolve the issue reported earlier as PDFNET-38835, please try using h.TextState.Rotation = 90 instead of h.Rectangle.Rotate(270).