Watermark
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.
Watermark
Hello, I found some operations which are placing the watermark on to the document. But how can I setup watermark in such a way that it'd be visible for the end user in process of his work over document, and user could not remove it?
Same way as I can see Tracker-Soft's Watermark image. ( See attach )
Regards,
Yury
Same way as I can see Tracker-Soft's Watermark image. ( See attach )
Regards,
Yury
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Hello Yury,
Basically what you have to do is draw on the Pages View directly. For that, check out this post:
https://forum.pdf-xchange.com/ ... ck#p103111
Cheers,
Alex
Basically what you have to do is draw on the Pages View directly. For that, check out this post:
https://forum.pdf-xchange.com/ ... ck#p103111
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
Thanks, Sasha. I did the following:
1. I took the code from the sample, you've pointed me to.
2. I changed the m_aInst.MathHelper.Matrix_TransformRect(ref p2v, ref rc); to m_aInst.MathHelper.Rect_Transform(ref p2v, ref rc); as compiler failed to find method.
3. I tried to register/unregister call back at event monitor... ( not sure I did this correctly )
I'm able to break debugger at painting code ( DrawRectangle ), however I see nothing in editor view.
Sometimes, ( in case I have document with 1 page, I see the blue rectangle at the left bottom of the page. If open doc with several pages, I don't see it.
So,
1. How can I properly register/unregister callback?
2. How to draw on each page?
Best regards, and thanks for your help!
1. I took the code from the sample, you've pointed me to.
2. I changed the m_aInst.MathHelper.Matrix_TransformRect(ref p2v, ref rc); to m_aInst.MathHelper.Rect_Transform(ref p2v, ref rc); as compiler failed to find method.
3. I tried to register/unregister call back at event monitor... ( not sure I did this correctly )
Code: Select all
public partial class UIEventMon : PDFXEdit.IUIX_EventMonitor
{
MainEditorForm _form;
bool _registered = false;
public UIEventMon(MainEditorForm form)
{
_form = form;
}
public void OnEventMonitor(PDFXEdit.IUIX_Obj pTarget, PDFXEdit.IUIX_Event pEvent)
{
{
if (_form.pdfCtl.Doc != null && !_registered)
{
_form.pdfCtl.Doc.ActiveView.PagesView.RegisterDrawCallback(PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground, _form._dPClbk);
_registered = true;
}
}
if( pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_BeforeDestroy )
{
if(_form.pdfCtl.Doc != null && _registered )
{
_form.pdfCtl.Doc.ActiveView.PagesView.UnregisterDrawCallback(PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground, _form._dPClbk);
_registered = false;
}
}
}
}
Sometimes, ( in case I have document with 1 page, I see the blue rectangle at the left bottom of the page. If open doc with several pages, I don't see it.
So,
1. How can I properly register/unregister callback?
2. How to draw on each page?
Best regards, and thanks for your help!
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Hello Yury,
In this case you should use the pdfCtl_OnEvent method to monitor the events. As for the registering\unregistering of the callback, you can use the e.activeDocChanged event to unregister the callback first and then register it to another document. Also the unregistering should be done in the e.document.beforeClose event. The callback itself should probably hold a reference to the IPXV_Document that should be cleared when unregistering.
To draw on all of the pages do this:
Cheers,
Alex
In this case you should use the pdfCtl_OnEvent method to monitor the events. As for the registering\unregistering of the callback, you can use the e.activeDocChanged event to unregister the callback first and then register it to another document. Also the unregistering should be done in the e.document.beforeClose event. The callback itself should probably hold a reference to the IPXV_Document that should be cleared when unregistering.
To draw on all of the pages do this:
Code: Select all
//Drawing rectangle on the foreground
if (nStage == PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground)
{
for (uint i = 0; i < pPageRegions.Count; i++)
{
DrawRectangle(pView, pRC, pPageRegions[i].nPage);
}
}
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
Thanks, sorry, can't find where these e.activeDocChanged , e.document.beforeClose are defined?
- Tracker Supp-Stefan
- Site Admin
- Posts: 17941
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Watermark
Hello Yuri,
This is a list of the events in the Editor:
https://sdkhelp.pdf-xchange.com/view/PXV:PXV_Events
And you can handle them with the OnEvent method:
https://sdkhelp.pdf-xchange.com/vie ... er_OnEvent
Regards,
Stefan
This is a list of the events in the Editor:
https://sdkhelp.pdf-xchange.com/view/PXV:PXV_Events
And you can handle them with the OnEvent method:
https://sdkhelp.pdf-xchange.com/vie ... er_OnEvent
Regards,
Stefan
Re: Watermark
Could you please give some code example? Not sure I understand.....
I have this in my code
And this:
Until now everything is clear for me.
But inside the pdfCtl_OnEvent, how I can detect that e is "e.document.beforeClose"
Sorry, looks I missing something
I have this in my code
Code: Select all
private void pdfCtl_OnEvent(object sender, AxPDFXEdit._IPXV_ControlEvents_OnEventEvent e)
{
}
Code: Select all
this.pdfCtl.OnEvent += new AxPDFXEdit._IPXV_ControlEvents_OnEventEventHandler(this.pdfCtl_OnEvent);
But inside the pdfCtl_OnEvent, how I can detect that e is "e.document.beforeClose"
Sorry, looks I missing something
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Please check the FullDemo application - there is a sample on that matter.
Cheers,
Alex
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
int id = pdfCtl.Inst.Str2ID("e.document.beforeClose");
Correct?
Correct?
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Correct, and then compare it to the e.nEventID.
Cheers,
Alex
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
Does not work....
1. I can break at
So, call back is set. But I don't see any rectangles on pages. See attachment.
Next, this code produces exception when I'm closing window..
May be I should not save doc?
And finally, I never come to inside the if:
Any thoughts? I'm using x64 version of the control.
Code: Select all
private void pdfCtl_OnEvent(object sender, AxPDFXEdit._IPXV_ControlEvents_OnEventEvent e)
{
try
{
if (e.nEventID == _editorIDS.nIDS[(int)IDS.e_activeDocChanged])
{
if (_doc != null)
_doc.ActiveView.PagesView.UnregisterDrawCallback(PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground, _dPClbk);
if(this.pdfCtl.Doc!=null )
this.pdfCtl.Doc.ActiveView.PagesView.RegisterDrawCallback(PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground, _dPClbk);
_doc = this.pdfCtl.Doc;
}
int id = pdfCtl.Inst.Str2ID("e.document.beforeClose");
if (e.nEventID == id)
{
this.pdfCtl.Doc.ActiveView.PagesView.UnregisterDrawCallback(PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground, _dPClbk);
}
}
catch (Exception ex)
{
return;
}
Code: Select all
public void DrawRectangle(PDFXEdit.IPXV_PagesView pView, PDFXEdit.IUIX_RenderContext pRC_, uint nPage)
{
PDFXEdit.IPXV_PagesLayoutManager plm = pView.Layout;
if (plm == null)
return;
PDFXEdit.PXC_Matrix p2v = plm.GetPageToDeviceMatrix(nPage, true);
PDFXEdit.PXC_Rect rc = m_rcDraw;
m_aInst.MathHelper.Rect_Transform(ref p2v, ref rc);
//Flipping rectangle top and bottom coordinates and converting it's type
PDFXEdit.tagRECT rcDR;
rcDR.left = (int)rc.left;
rcDR.right = (int)rc.right;
rcDR.top = (int)rc.bottom;
rcDR.bottom = (int)rc.top;
pRC_.DrawRect(rcDR, m_Brush, m_Pen, ref rcDR, 1);
}
Next, this code produces exception when I'm closing window..
Code: Select all
if (_doc != null)
_doc.ActiveView.PagesView.UnregisterDrawCallback(PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground, _dPClbk);
And finally, I never come to inside the if:
Code: Select all
if (e.nEventID == id)
{
this.pdfCtl.Doc.ActiveView.PagesView.UnregisterDrawCallback(PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground, _dPClbk);
}
Re: Watermark
Seems I got rid of exceptions and callback registrations issues. (
But I still do not see the rectangles... Ideas?
Code: Select all
int id = pdfCtl.Inst.Str2ID("e.document.beforeClose");
pdfCtl.EnableEventListening2(id, bRegister);
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Hello Yury,
For starters just make a button with this code:
Then use this code here for a callback class:
Do not forget about unregistering the callback:
All of this code should draw a rectangle on the visual left bottom side of the page.
Cheers,
Alex
For starters just make a button with this code:
Code: Select all
DrawPagesCallback m_DPClbk = null;
private void drawRectangleOnPageToolStripMenuItem_Click(object sender, EventArgs e)
{
if (m_DPClbk == null)
{
m_DPClbk = new DrawPagesCallback(auxInst, uiInst);
//Registering callback at the needed document's pages view
pdfCtl.Doc.ActiveView.PagesView.RegisterDrawCallback(PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground, m_DPClbk);
}
}
Code: Select all
public class DrawPagesCallback : PDFXEdit.IPXV_PagesViewDrawCallback
{
public PDFXEdit.IAUX_Inst m_aInst;
public PDFXEdit.IUIX_Inst m_uiInst;
private PDFXEdit.IColor m_clrFill;
private PDFXEdit.IColor m_clrBorder;
private PDFXEdit.PXC_Rect m_rcDraw;
PDFXEdit.IUIX_Brush m_Brush;
PDFXEdit.IUIX_Pen m_Pen;
public DrawPagesCallback(PDFXEdit.IAUX_Inst aInst, PDFXEdit.IUIX_Inst uiInst)
{
m_aInst = aInst;
m_uiInst = uiInst;
m_clrFill = m_aInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB);
m_clrFill.SetRGB(0.0f, 1.0f, 1.0f);
m_clrBorder = m_aInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB);
m_clrBorder.SetRGB(0.0f, 1.0f, 0.0f);
m_rcDraw.left = -100;
m_rcDraw.right = 100;
m_rcDraw.top = 100;
m_rcDraw.bottom = 0;
m_Brush = m_uiInst.CreateNewBrush();
m_Pen = m_uiInst.CreateNewPen();
m_Brush.Color0 = m_clrFill.RGB;
m_Brush.Color1 = m_clrFill.RGB;
m_Pen.Brush.Color0 = m_clrBorder.RGB;
m_Pen.Brush.Color1 = m_clrBorder.RGB;
m_Pen.Width = 10;
m_Pen.Inside = true;
}
public void OnDrawPagesView(PDFXEdit.IPXV_PagesView pView, PDFXEdit.PXV_PagesViewDrawStage nStage, PDFXEdit.IUIX_RenderContext pRC, PDFXEdit.IPXV_PagesLayoutRegions pPageRegions)
{
if (pView == null)
return;
//Drawing rectangle on the foreground
if (nStage == PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground)
{
for (uint i = 0; i < pPageRegions.Count; i++)
{
DrawRectangle(pView, pRC, pPageRegions[i].nPage);
}
}
}
public void DrawRectangle(PDFXEdit.IPXV_PagesView pView, PDFXEdit.IUIX_RenderContext pRC_, uint nPage)
{
PDFXEdit.IPXV_PagesLayoutManager plm = pView.Layout;
if (plm == null)
return;
PDFXEdit.PXC_Matrix p2v = plm.GetPageToDeviceMatrix(nPage, true);
PDFXEdit.PXC_Rect rc = m_rcDraw;
m_aInst.MathHelper.Rect_Transform(ref p2v, ref rc);
//Flipping rectangle top and bottom coordinates and converting it's type
PDFXEdit.tagRECT rcDR;
rcDR.left = (int)rc.left;
rcDR.right = (int)rc.right;
rcDR.top = (int)rc.bottom;
rcDR.bottom = (int)rc.top;
pRC_.DrawRect(rcDR, m_Brush, m_Pen, ref rcDR, 1);
}
}
Code: Select all
if (e.nEventID == nIDS[(int)IDS.e_document_beforeClose])
{
if (m_DPClbk != null)
pdfCtl.Doc.ActiveView.PagesView.UnregisterDrawCallback(PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground, m_DPClbk);
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
Not working.... project attached
Thank you.
Thank you.
- Attachments
-
- PDFXEditor.7z
- (574.18 KiB) Downloaded 141 times
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Hello Yury,
As I see you haven't tried resizing the page or scrolling it. You will have to invalidate the page(s) for the first time manually:
Cheers,
Alex
As I see you haven't tried resizing the page or scrolling it. You will have to invalidate the page(s) for the first time manually:
Code: Select all
pdfCtl.Doc.ActiveView.PagesView.RegisterDrawCallback(PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground, _dPClbk);
pdfCtl.Doc.ActiveView.PagesView.InvalidatePage(pdfCtl.CurrentPage);
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
No, this didn't help . Have you tried to build/run my project?
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Works for me:
Alex
Cheers,Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
Just checked again.... If I start under VS2013 - it works. If I start under VS2010 - it does not.... any thoughts?
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Hello Yury,
What came to mind is a .Net platform that the different VS are using - check that out.
Cheers,
Alex
What came to mind is a .Net platform that the different VS are using - check that out.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
No, this is in project settings. Both use .Net Framework 4 Client Profile
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Well then it's not a SDK problem then.
Cheers,
Alex
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
Alex, I think that issue is in some object marshaling....look at the code below:
Having this, I got a small rectangle at the bottom left of the page.
Note that 1.0 is used instead of 1
I checked the interop wrapers and both are the same.
[DispId(1610743821)]
I think you'd know about this. default parameters in DevStudio 10 will not work. they will be transferred as 0 instead of 1
But please, tell me how to draw rect over the Page bound? My code above not working to draw rec on entire page.
Code: Select all
public void OnDrawPagesView(PDFXEdit.IPXV_PagesView pView, PDFXEdit.PXV_PagesViewDrawStage nStage, PDFXEdit.IUIX_RenderContext pRC, PDFXEdit.IPXV_PagesLayoutRegions pPageRegions)
{
if (pView == null)
return;
//Drawing rectangle on the foreground
if (nStage == PDFXEdit.PXV_PagesViewDrawStage.PXV_PagesViewDraw_Foreground)
{
for (uint i = 0; i < pPageRegions.Count; i++)
{
DrawRectangle(pView, pRC, pPageRegions[i].nPage, pPageRegions[i].rcPageRect);
}
}
}
public void DrawRectangle(PDFXEdit.IPXV_PagesView pView, PDFXEdit.IUIX_RenderContext pRC_, uint nPage, PDFXEdit.tagRECT rcPage)
{
PDFXEdit.IPXV_PagesLayoutManager plm = pView.Layout;
if (plm == null)
return;
PDFXEdit.PXC_Matrix p2v = plm.GetPageToDeviceMatrix(nPage, true);
PDFXEdit.PXC_Rect rc = m_rcDraw;
PDFXEdit.PXC_Rect rcPageRect; rcPageRect.bottom = rcPage.bottom; rcPageRect.left = rcPage.left; rcPageRect.top = rcPage.top; rcPageRect.right = rcPage.right;
m_aInst.MathHelper.Rect_Transform(ref p2v, ref rc);
m_aInst.MathHelper.Rect_Transform(ref p2v, ref rcPageRect);
//Flipping rectangle top and bottom coordinates and converting it's type
PDFXEdit.tagRECT rcDR;
rcDR.left = (int)rc.left;
rcDR.right = (int)rc.right;
rcDR.top = (int)rc.bottom;
rcDR.bottom = (int)rc.top;
PDFXEdit.tagRECT rcDRPage;
rcDRPage.left = (int)rcPageRect.left;
rcDRPage.right = (int)rcPageRect.right;
rcDRPage.top = (int)rcPageRect.bottom;
rcDRPage.bottom = (int)rcPageRect.top;
pRC_.DrawRect(rcDR, m_Brush, m_Pen, ref rcDRPage, 1.0);
pRC_.DrawRect(rcDR, m_Brush, m_Pen, ref rcDR, 1.0);
}
Note that 1.0 is used instead of 1
I checked the interop wrapers and both are the same.
[DispId(1610743821)]
Code: Select all
void DrawRect(ref tagRECT stRect, IUIX_Brush pBrush, IUIX_Pen pPen, ref tagRECT stClipRect, double nOpacity = 1);
But please, tell me how to draw rect over the Page bound? My code above not working to draw rec on entire page.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
That's because you have not taken the needed page's rectangle:
Cheers,
Alex
Code: Select all
public void DrawRectangle(PDFXEdit.IPXV_PagesView pView, PDFXEdit.IUIX_RenderContext pRC_, uint nPage)
{
PDFXEdit.IPXV_PagesLayoutManager plm = pView.Layout;
if (plm == null)
return;
PDFXEdit.PXC_Matrix p2v = plm.GetPageToDeviceMatrix(nPage, true);
PDFXEdit.IPXC_Page page = pView.DocView.Doc.CoreDoc.Pages[nPage];
PDFXEdit.PXC_Rect rc = page.get_Box(PXC_BoxType.PBox_PageBox); ;// = m_rcDraw;
m_aInst.MathHelper.Rect_Transform(ref p2v, ref rc);
//Flipping rectangle top and bottom coordinates and converting it's type
PDFXEdit.tagRECT rcDR;
rcDR.left = (int)rc.left;
rcDR.right = (int)rc.right;
rcDR.top = (int)rc.bottom;
rcDR.bottom = (int)rc.top;
pRC_.DrawRect(rcDR, m_Brush, m_Pen, ref rcDR, 1);
}
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
Ok. Thank you. works.
But What is the ?
I thought this is also page rectangle.....
But What is the
Code: Select all
pPageRegions[i].rcPageRect
I thought this is also page rectangle.....
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Hello Yury,
I've updated the description of this structure:
https://sdkhelp.pdf-xchange.com/vie ... youtRegion
Cheers,
Alex
I've updated the description of this structure:
https://sdkhelp.pdf-xchange.com/vie ... youtRegion
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
Thanks Alex.
Could you please also point me to some description or sample on how to use pRC_.DrawString(
What I really need is draw Watermark string through the each page of the document. ( opacity is needed )
Thanks again!
Could you please also point me to some description or sample on how to use pRC_.DrawString(
What I really need is draw Watermark string through the each page of the document. ( opacity is needed )
Thanks again!
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Hello Yury,
Check out this sample:
https://github.com/tracker-software/PDFCoreSDKExamples
Cheers,
Alex
Check out this sample:
https://github.com/tracker-software/PDFCoreSDKExamples
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
Alex, I'm unable to build this sample. It seems uses VS2105.
Also, it is CoreAPI sample and uses different interfaces than IUIX_RenderContext.
I've spent a lot of time trying to implement simple things with your SDK. This is because it is not documented. This is not my fault.
Could you please give me example on how to do what I need.
I need draw watermark text through the pages. I'm using the RenderContext interface, as you've suggested in your previous posts.
Thanks.
Also, it is CoreAPI sample and uses different interfaces than IUIX_RenderContext.
I've spent a lot of time trying to implement simple things with your SDK. This is because it is not documented. This is not my fault.
Could you please give me example on how to do what I need.
I need draw watermark text through the pages. I'm using the RenderContext interface, as you've suggested in your previous posts.
Thanks.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Hello Yury,
Well that method is majorly self-explanatory, though I've updated it's description:
https://sdkhelp.pdf-xchange.com/vie ... DrawString
Basically one problem that you could struggle with is how to obtain the IUIX_Font - though there are the samples for that in the FullDemo application:
Cheers,
Alex
Well that method is majorly self-explanatory, though I've updated it's description:
https://sdkhelp.pdf-xchange.com/vie ... DrawString
Basically one problem that you could struggle with is how to obtain the IUIX_Font - though there are the samples for that in the FullDemo application:
Code: Select all
PDFXEdit.IUIX_Theme th = uiInst.Theme;
PDFXEdit.IUIX_Font fnt = th.StdFont[PDFXEdit.UIX_StdFont.UIX_StdFont_Default];
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Watermark
Hello, thank you. I could draw text.
How can I draw image? I tried to use class, which is described in some of your posts, but failed.
What I have is .Net Bitmap ( Image ) object.
I need to convert it to PDFXEdit.IUIX_ImageData, so I could use it in pRC_.DrawImage(.
How can I do this?
This code produced type cast exception in last row.
How can I draw image? I tried to use
Code: Select all
IStreamWrapper
What I have is .Net Bitmap ( Image ) object.
I need to convert it to PDFXEdit.IUIX_ImageData, so I could use it in pRC_.DrawImage(.
How can I do this?
Code: Select all
System.IO.MemoryStream memStream = new System.IO.MemoryStream();
watermark.Save( memStream, System.Drawing.Imaging.ImageFormat.Png );
PDFXEditor.IStreamWrapper sw = new PDFXEditor.IStreamWrapper(memStream);
_imgWatermark = m_uiInst.CreateImageFromIStream((IStream)sw);
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Watermark
Hello Yury,
Here's a code sample for you to experiment with:
Cheers,
Alex
Here's a code sample for you to experiment with:
Code: Select all
public void DrawImage(PDFXEdit.IPXV_PagesView pView, PDFXEdit.IUIX_RenderContext pRC_, uint nPage)
{
PDFXEdit.IPXV_PagesLayoutManager plm = pView.Layout;
PDFXEdit.PXC_Matrix p2v = plm.GetPageToDeviceMatrix(nPage, true);
PDFXEdit.IPXC_Page page = pView.DocView.Doc.CoreDoc.Pages[nPage];
PDFXEdit.PXC_Rect rcPage = page.get_Box(PXC_BoxType.PBox_PageBox); ;// = m_rcDraw;
m_aInst.MathHelper.Rect_Transform(ref p2v, ref rcPage);
PDFXEdit.tagRECT rcTagPage;
rcTagPage.left = (int)rcPage.left;
rcTagPage.top = (int)rcPage.bottom;
rcTagPage.bottom = (int)rcPage.top;
rcTagPage.right = (int)rcPage.right;
//image = (Bitmap)Bitmap.FromFile(@"D:\PageImage.bmp");
Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
System.Drawing.Imaging.BitmapData bmpData = image.LockBits(rect, ImageLockMode.ReadWrite, image.PixelFormat);
IUIX_ImageData iData = m_uiInst.CreateNewImage(image.Width, image.Height);
// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;
// Declare an array to hold the bytes of the bitmap.
int bytes = Math.Abs(bmpData.Stride) * image.Height;
byte[] rgbValues = new byte[bytes];
IntPtr outPtr = new IntPtr(iData.Scan0);
// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
// Copy the RGB values back to the bitmap
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, outPtr, bytes);
// Unlock the bits.
image.UnlockBits(bmpData);
PDFXEdit.tagRECT rcImage;
rcImage.left = 0;
rcImage.right = image.Width;
rcImage.bottom = image.Height;
rcImage.top = 0;
pRC_.DrawImage(iData, rcTagPage, rcImage, rcTagPage, (int)UIX_ImageScaleTypes.UIX_ImageScale_Stretch, (int)UIX_ImageScaleTypes.UIX_ImageScale_Stretch);
}
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ