Rotated HTML Text

.Net PDF

I’m trying to add some HTML text to an existing document. I have found that using a FloatingBox lets me position the text on the page in any location subject to the page margins. The only problem I’m having is that I can’t see to see how to rotate either the text or the floatingbox. Its interesting that TextStamp can be positioned and rotated; it would be great if you could combine the HTML text with the TextStamp as this would give the features I need. Is there anyway to accomplish this.

Hi @smorley; can you show us the piece of code that you are trying to use. Also if you can explain the expected result that you want to accomplish. Thanks :vulcan_salute::nerd_face:

I have an existing PDF with rotated pages.
The user has selected to place a block of HTML text on the page.
For an unrotated page I simply place the HTMLFragment in a FloatingBox and then I can position that on the page.
For a rotated page the text is appearing in the same orientation as the rotated text and what we want is for the overlay to be displayed in an unrotated condition so my assumption is that I need to rotate either the text or the FloatingBox to make it appear in the correct rotation.

Hi @smorley, to rotate text, you can use the Rotation property. Let me know if this piece of documentation helps Rotate Text Inside PDF using C#|Aspose.PDF for .NET

Thanks :vulcan_salute::nerd_face:

Is Rotation valid for an HTMLFragment. I’m getting an error on this:

    var frag = new HtmlFragment(html);
    frag.TextState.Rotation = 90;

I note that a TextFragment has a TextFragmentState where as HTMLFragment has a TextState whcih doesn’t have a Rotation property.

@smorley

We have logged a feature request to introduce a stamp in the API that can support HTML rendering. The ticket ID for this request is PDFNET–52097.

Regretfully, the rotation property was not implemented for HtmlFragment. However, an enhancement ticket as PDFNET-52098 has been logged in our issue tracking system to add this property after investigating the feasibility. We will let you know as soon as these tickets are resolved.

As a workaround, you can Remove the page rotation by setting it to None and reapply it after adding the HTML Stamp so that the stamp is also rotated after page is rotated.

We apologize for the inconvenience.