How can I rotate a newly added text field

PDF-XChange Editor SDK for Developers

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
usmanakhtar
User
Posts: 18
Joined: Wed Feb 24, 2016 6:51 pm

How can I rotate a newly added text field

Post by usmanakhtar »

Hi Alex,

I am using Editor SDK and C# as development language.
Could you please help me to do these:

1. How to get rotation of the text field from an opened document.
2. How can I rotate a newly added text field.

Can you provide me some sample code using the Editor SDK to perform these operations in C# or VB.NET?

Regards,
Usman
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm

Re: How can I rotate a newly added text field

Post by Will - Tracker Supp »

Hi Usman,

I've moved your post to a new topic, as you're using a different SDK to the OP and the question differs from theirs. Please make sure that you post a new topic in the appropriate forum, in the future, unless your post specifically relates to the OP's.

Thanks, will pass your question to the Dev. Team.
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How can I rotate a newly added text field

Post by Sasha - PDF-XChange »

Hello ,

This is how you can do the content rotation of the text fields on the page:

Code: Select all

		private void rotateFiledsToolStripMenuItem_Click(object sender, EventArgs e)
		{
			PDFXEdit.IPXS_Inst pSInt = (PDFXEdit.IPXS_Inst)pdfCtl.Inst.GetExtension("PXS");
			uint nWidgetAtom = pSInt.StrToAtom("Widget");
			int nID = pdfCtl.Inst.Str2ID("op.annots.setProps", false);
			PDFXEdit.IOperation Op = pdfCtl.Inst.CreateOp(nID);
			PDFXEdit.ICabNode input = Op.Params.Root["Input"];
			//Get widget annotations from the first page
			PDFXEdit.IPXC_Page page = pdfCtl.Doc.CoreDoc.Pages[0];
			uint nPageCount = page.GetAnnotsCount();
			for (uint i = 0; i < nPageCount; i++)
			{
				PDFXEdit.IPXC_Annotation annot = page.GetAnnot(i);
				if (annot.Type == nWidgetAtom)
				{
					if ((annot.Field != null) && (annot.Field.Type == PDFXEdit.PXC_FormFieldType.FFT_Text))
						input.Add().v = annot;
				}
			}
			if (input.Count == 0)
				return;
			PDFXEdit.ICabNode options = Op.Params.Root["Options"];
			options["ContentRotation"].v = 90;
			options["MaskEx"].v = 0x00000400;
			Op.Do();
		}
And here's how to get the current widget's rotation:

Code: Select all

					PDFXEdit.IPXC_AnnotData_Widget WData = (PDFXEdit.IPXC_AnnotData_Widget)annot.Data;
					double rot = WData.Rotation;
HTH,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
usmanakhtar
User
Posts: 18
Joined: Wed Feb 24, 2016 6:51 pm

Re: How can I rotate a newly added text field

Post by usmanakhtar »

Hi,

Thanks Alex.
I am able to rotate the textfield with the help of code provided by you. But I am unable to get the rotation of a text field of an opened document.

I am using following code to get rotation:

Code: Select all

PDFXEdit.IPXC_FormField field = pdfEditor.Doc.CoreDoc.AcroForm.GetFieldByName(FieldName);
PDFXEdit.IPXC_Annotation annotation = field.get_Widget(0);
PDFXEdit.IPXC_AnnotData_Widget WData = (PDFXEdit.IPXC_AnnotData_Widget)annotation.Data;
Rotation = WData.Rotation;
I am also attaching a pdf file. I am trying to get rotating of text fields of this pdf document.

Regards,
Usman Akhtar.
You do not have the required permissions to view the files attached to this post.
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How can I rotate a newly added text field

Post by Sasha - PDF-XChange »

Hello ,

The needed functionality was not in the interfaces. We've updated the code and this will be available from the next build (317):

Code: Select all

Rotation = WData.ContentRotation;
HTH,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ