aspose-pdf / Aspose.PDF-for-.NET

Aspose.PDF for .NET examples, plugins and showcase projects
MIT License
137 stars 59 forks source link

Provide the option to set Rotation as free degree with some range instead of limited option in TextStamp #61

Open Hvishal88 opened 4 weeks ago

Hvishal88 commented 4 weeks ago

I am trying to set TextStamp with 45 angle rotation but there is no such option available as a part of Rotation enum(Aspose.Pdf.Rotation)

Rotation

is there any possibility to go for custom Rotation value?

I am using : Assembly Aspose.PDF, Version=24.7.0.0 for the .net

arise-project commented 2 weeks ago

Hello, @Hvishal88 I started to research this custom rotation.

arise-project commented 1 week ago

Hello, @Hvishal88

Could you probe my example with using of textStamp.RotateAngle = 45; instead of textStamp.Rotate = Rotation.on90; // Rotate 90 degrees clockwise to done your solution, seems it work:

// Create a new PDF document Document pdfDocument = new Document();

// Add a page to the document Page page = pdfDocument.Pages.Add();

// Create a TextStamp with the desired text TextStamp textStamp = new TextStamp("Sample Text");

// Set the text properties textStamp.TextState.Font = FontRepository.FindFont("Arial"); textStamp.TextState.FontSize = 72; textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);

// Set the rotation angle (in degrees) textStamp.RotateAngle = 45; // textStamp.Rotate = Rotation.on90; // Rotate 90 degrees clockwise

// Set the position of the stamp textStamp.XIndent = 100; textStamp.YIndent = 400;

// Add the TextStamp to the page page.AddStamp(textStamp);

// Save the PDF document pdfDocument.Save("output.pdf");

// Dispose of the document pdfDocument.Dispose();

image