Change colour of stamp content on placement...
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
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.
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.
Change colour of stamp content on placement...
Firstly I would like to say that I love the new ability to convert annotation elements to a stamp using the createStampFromSel option. I do however have a question, I have developed a stamp designer for my end users to allow them to draw annotation elements e.g. lines, circles, text etc. and then convert these into a stamp. What I was wondering is if it would be possible to change the colour of the annotation elements when the user places the stamp from the stamp palette e.g.
1. Draw the stamp using PDFXchange annotation elements only, and for this example lets assume the designer placed all annotation elements using black colour
2. Select the annotation elements and create a stamp using the createStampFromSel option. The stamp is now placed in the stamp palette.
3. The user now opens a PDF document and wants to place the newly create stamp on the document. This obviously all works fine. However lets assume the user wants to place the stamp but as Red instead of Black. Is there anyway that I could somehow interrupt the stamp placement event, and somehow save the stamp pdf document to the local machine, change the colour of the annotation elements to Red, and then place this newly changed colour stamp?
I hope that makes sense, just unsure where to start with this.
Thanks
Simon
1. Draw the stamp using PDFXchange annotation elements only, and for this example lets assume the designer placed all annotation elements using black colour
2. Select the annotation elements and create a stamp using the createStampFromSel option. The stamp is now placed in the stamp palette.
3. The user now opens a PDF document and wants to place the newly create stamp on the document. This obviously all works fine. However lets assume the user wants to place the stamp but as Red instead of Black. Is there anyway that I could somehow interrupt the stamp placement event, and somehow save the stamp pdf document to the local machine, change the colour of the annotation elements to Red, and then place this newly changed colour stamp?
I hope that makes sense, just unsure where to start with this.
Thanks
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Change colour of stamp content on placement...
Hello Simon,
I believe you have already asked a similar question here:
viewtopic.php?f=66&t=29645&p=117058&hil ... nt#p117058
Cheers,
Alex
I believe you have already asked a similar question here:
viewtopic.php?f=66&t=29645&p=117058&hil ... nt#p117058
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Change colour of stamp content on placement...
Alex,
Thanks for reminding me, I have tried the following but it does not seem to change the colour of the stamp annotation elements. It does however add new text in the correct colour, this is done as a test.
I guess I have to loop through each annotation element in the stamp, which I am trying to do, but with no joy. I guess I am actually going down the wrong route, would you be able to help.
Note: The IPXC_Annotation variable being passed in the sub is that of the stamp.
Thanks in advance
Simon
Thanks for reminding me, I have tried the following but it does not seem to change the colour of the stamp annotation elements. It does however add new text in the correct colour, this is done as a test.
I guess I have to loop through each annotation element in the stamp, which I am trying to do, but with no joy. I guess I am actually going down the wrong route, would you be able to help.
Note: The IPXC_Annotation variable being passed in the sub is that of the stamp.
Code: Select all
Public Sub changeStampColour(pxsInst As IPXS_Inst, ByRef annot As IPXC_Annotation)
Dim stampAnnotType As UInteger = pxsInst.StrToAtom("Stamp")
If annot.Type <> stampAnnotType Then
Return
End If
Dim objApp As Object = annot.Handler.GetAppearance(annot, Nothing)
Dim varApp As IPXS_PDFVariant = DirectCast(objApp, IPXS_PDFVariant)
If varApp Is Nothing Then
Return
End If
Dim xForm As IPXC_XForm = annot.Page.Document.GetXForm(varApp)
If xForm Is Nothing Then
Return
End If
Dim content As IPXC_Content = xForm.GetContent(PXC_ContentAccessMode.CAccessMode_WeakClone)
Dim cc As IPXC_ContentCreator = annot.Page.Document.CreateContentCreator()
cc.Attach(content)
Dim color As PDFXEdit.IColor = auxInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB)
color.Value = "rgbd(" & MISData.Instance.frmMain.activeAnnoColour.R.ToString & "," & MISData.Instance.frmMain.activeAnnoColour.G.ToString & "," & MISData.Instance.frmMain.activeAnnoColour.B.ToString & ")"
cc.SetStrokeColorRGB(color.RGB)
cc.SetColorRGB(color.RGB)
Dim contentList As IPXC_ContentItems = content.Items
For i As UInteger = 0 To contentList.Count
Dim item As IPXC_ContentItem = contentList.Item(i)
Dim annotElement As PDFXEdit.IPXC_Annotation = TryCast(contentList.Item(i), PDFXEdit.IPXC_Annotation)
Console.WriteLine(annotElement.Type.ToString)
Next
Dim fnt As PDFXEdit.IPXC_Font = Me.docPreview.Doc.CoreDoc.CreateNewFont2("ArialMT")
cc.SetFont(fnt)
cc.SetFontSize(10.0F)
Dim rc As PXC_Rect = xForm.BBox
cc.ShowTextLine(rc.left + 5, rc.bottom + 25, MISData.Instance.FirstName & " " & MISData.Instance.LastName)
cc.ShowTextLine(rc.left + 5, rc.bottom + 15, Now.ToShortDateString & " " & Now.ToShortTimeString)
xForm.SetContent(cc.Detach())
End Sub
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Change colour of stamp content on placement...
Hello Simon,
Well the Annotations are not a part of the Content and are definitely not a Content Items. Simply speaking, they are being flattened before they become a part of the Stamps Content and you cannot distinguish them afterwards. You can change the colors of the content items though but you will have to know for yourself which items should be changed or not and that is not a simple task.
Cheers,
Alex
Well the Annotations are not a part of the Content and are definitely not a Content Items. Simply speaking, they are being flattened before they become a part of the Stamps Content and you cannot distinguish them afterwards. You can change the colors of the content items though but you will have to know for yourself which items should be changed or not and that is not a simple task.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Change colour of stamp content on placement...
Thanks Alex for getting back to me.
Is it possible to change the colour of all content items regardless?
Thanks
Simon
Is it possible to change the colour of all content items regardless?
Thanks
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Change colour of stamp content on placement...
Hello Simon,
Yes, it can be done, though the method to change the IPXC_Color has an awkward translation to the .Net as it uses a pointer to the array. We've added a new method, though it will be available in the upcoming release. Please bump this thread when the new release is out and I will give you the sample on how to do this.
Cheers,
Alex
Yes, it can be done, though the method to change the IPXC_Color has an awkward translation to the .Net as it uses a pointer to the array. We've added a new method, though it will be available in the upcoming release. Please bump this thread when the new release is out and I will give you the sample on how to do this.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Change colour of stamp content on placement...
Alex,
I don't suppose you have an estimated time on this release? As always my clients are on my case to try and get this feature added to my software.
Thanks for your help
Simon
I don't suppose you have an estimated time on this release? As always my clients are on my case to try and get this feature added to my software.
Thanks for your help
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Change colour of stamp content on placement...
Hello Simon,
It should be out in a week or so.
Cheers,
Alex
It should be out in a week or so.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Change colour of stamp content on placement...
Alex,
Do you have an ETA on this new release with this functionality?
Thanks
Simon
Do you have an ETA on this new release with this functionality?
Thanks
Simon
- Tracker Supp-Stefan
- Site Admin
- Posts: 17910
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Change colour of stamp content on placement...
Hello Simon,
Build 325 was released earlier this week.
You can get it from here:
https://www.pdf-xchange.com/product/downloads/dev
Regards,
Stefan
Build 325 was released earlier this week.
You can get it from here:
https://www.pdf-xchange.com/product/downloads/dev
Regards,
Stefan
Re: Change colour of stamp content on placement...
Alex,
Thanks for letting me know. However when I log into my account is says I have the most recent version 7.0.324.2
I guess I won't need an upgrade license key and can just use my one from version 7.0.324.2 and download from your previous link?
Thanks
Simon
Thanks for letting me know. However when I log into my account is says I have the most recent version 7.0.324.2
I guess I won't need an upgrade license key and can just use my one from version 7.0.324.2 and download from your previous link?
Thanks
Simon
- Tracker Supp-Stefan
- Site Admin
- Posts: 17910
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Change colour of stamp content on placement...
Hi Simon,
Yes - if you have current maintenance plan - you can use the key you already have with the latest installed from the downloads page.
Regards,
Stefan
Yes - if you have current maintenance plan - you can use the key you already have with the latest installed from the downloads page.
Regards,
Stefan
Re: Change colour of stamp content on placement...
Thanks Alex,
Just out of interest is there any chance of getting that sample code to change the colour of stamp elements on placement?
Thanks
Simon
Just out of interest is there any chance of getting that sample code to change the colour of stamp elements on placement?
Thanks
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Change colour of stamp content on placement...
Hello Simon,
Here's the sample that I promised:
Cheers,
Alex
Here's the sample that I promised:
Code: Select all
public void ModifyCState(ref IPXC_Content content)
{
for (uint i = 0; i < content.Items.Count; i++)
{
IPXC_ContentItem item = content.Items.GetItemForEditing(i);
if (item.Type == PXC_CIType.CIT_XForm)
{
IPXC_XForm xf = content.Document.GetXFormByHandle(item.XForm_Handle);
IPXC_Content cnt = xf.GetContent(PXC_ContentAccessMode.CAccessMode_WeakClone);
ModifyCState(ref cnt);
xf.SetContent(cnt);
}
else if (item.Type == PXC_CIType.CIT_Path)
{
PDFXEdit.IColor color = auxInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB);
color.SetRGB(0.0f, 1.0f, 1.0f);
IPXC_CState cstate = item.GetCState();
IPXC_Color fill = cstate.FillColor;
//fill.SetIColor(color);
//cstate.FillColor = fill;
IPXC_Color stroke = cstate.StrokeColor;
//stroke.SetIColor(color);
double[] rgb = new double[3] { 1.0, 0.0, 1.0 };
stroke.SetComponents2(rgb);
cstate.StrokeColor = stroke;
item.SetCState(cstate);
}
}
}
public void ModifyStampOnPlacement(IPXS_Inst pxsInst, ref IPXC_Annotation annot)
{
uint stampAnnotType = pxsInst.StrToAtom("Stamp");
if (annot.Type != stampAnnotType)
return;
object objApp = annot.Handler.GetAppearance(annot, null);
IPXS_PDFVariant varApp = (IPXS_PDFVariant)objApp;
if (varApp == null)
return;
IPXC_XForm xForm = annot.Page.Document.GetXForm(varApp);
if (xForm == null)
return;
IPXC_Content content = xForm.GetContent(PXC_ContentAccessMode.CAccessMode_WeakClone);
IPXC_ContentCreator cc = annot.Page.Document.CreateContentCreator();
cc.Attach(content);
cc.ResetAllStatesToDefault();
ModifyCState(ref content);
PDFXEdit.IColor color = auxInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB);
color.SetRGB(0.0f, 1.0f, 1.0f);
cc.SetFontSize(14.0f);
color.SetRGB(0.0f, 0.0f, 1.0f);
cc.SetFillColorRGB(color.RGB);
color.SetRGB(1.0f, 0.0f, 0.0f);
cc.SetStrokeColorRGB(color.RGB);
PDFXEdit.IPXC_Font fnt = pdfCtl.Doc.CoreDoc.CreateNewFont2("ArialMT");
cc.SetFont(fnt);
PXC_Rect rc = xForm.get_BBox();
cc.ShowTextLine(rc.left + 10, rc.bottom + 20, "TestLine");
xForm.SetContent(cc.Detach());
}
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Change colour of stamp content on placement...
Alex,
Thank you so much, the code works perfectly.
Thanks
Simon
Thank you so much, the code works perfectly.
Thanks
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Change colour of stamp content on placement...
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Change colour of stamp content on placement...
Alex,
I have just noticed that placing the stamp and changing the colour works fine. However if I add a comment to the stamp, then this is shown in it's original stamp colour, is there a way to change this as well?
Thanks
Simon
I have just noticed that placing the stamp and changing the colour works fine. However if I add a comment to the stamp, then this is shown in it's original stamp colour, is there a way to change this as well?
Thanks
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Change colour of stamp content on placement...
Hello Simon,
Should be the same as modifying the stamp itself - in the add annotation operation.
You can get the reply parent with this property:
https://sdkhelp.pdf-xchange.com/vi ... on_ReplyTo
Then you can modify it and it's popup as you want:
https://sdkhelp.pdf-xchange.com/vi ... tion_Popup
Cheers,
Alex
Should be the same as modifying the stamp itself - in the add annotation operation.
You can get the reply parent with this property:
https://sdkhelp.pdf-xchange.com/vi ... on_ReplyTo
Then you can modify it and it's popup as you want:
https://sdkhelp.pdf-xchange.com/vi ... tion_Popup
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ