PDF Viewer not Refreshing Properly

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.
jthomas
User
Posts: 31
Joined: Tue Oct 18, 2016 2:49 pm

PDF Viewer not Refreshing Properly

Post by jthomas »

I am seeing a bug with PDF editor not properly redrawing a line annotation. In the images provided, a line segment is visible on the UI after updating a line. This stray line segment cannot be selected and disappears when the zoom level changes, however when I go back to the same zoom, the line segment appears again.

orignalPlacement.PNG shows the original position of the line.
draggedPlacement.PNG shows the new position of the line with the stray fragment as well.
zoomedPlacemnt.PNG shows what happens when zoomed in from draggedPlacement.png.

Do you have any other techniques for redrawing a line annotation that will get rid of the stray line segment?

The application is configured as such:

When the orange annotation is moved, the line annotation is adjusted to snap to the center of the orange annotation.

This is done be changing the end points on the line.
IPXC_AnnotData_Line lineData = (IPXC_AnnotData_Line)lineAnnot.Data;
PXC_Point elementPoint;
PXC_Point flagPoint;
lineData.GetLinePoints(out elementPoint, out flagPoint);

// new center point
PXC_Rect newLocation = annot.get_Rect();
flagPoint = new PXC_Point()
{
x = (newLocation.left + newLocation.right) / 2,
y = (newLocation.top + newLocation.bottom) / 2
};
lineData.SetLinePoints(ref elementPoint, ref flagPoint);
lineAnnot.Data = lineData;

PDFXEdit.IPXV_InvalidatePagesInfo ipi = viewer.PdfCtrl.Doc.CreateInvPagesInfo();
ipi.InvalidateAnnot(lineAnnot);
viewer.PdfCtrl.Doc.InvalidatePages(ipi);
viewer.PdfCtrl.Doc.FireAnnotChangedEvent(lineAnnot);
tagRECT viewRect = viewer.PdfCtrl.Doc.ActiveView.PagesView.Obj.ClientRect;
viewer.PdfCtrl.Doc.ActiveView.PagesView.RedrawRect(ref viewRect);
viewer.PdfCtrl.Doc.ActiveView.PagesView.Redraw();
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: PDF Viewer not Refreshing Properly

Post by Sasha - PDF-XChange »

Hello Jared,

Please use operations for correct UI update:
https://sdkhelp.pdf-xchange.com/vie ... nnots_move
https://sdkhelp.pdf-xchange.com/vie ... ot_setData

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jthomas
User
Posts: 31
Joined: Tue Oct 18, 2016 2:49 pm

Re: PDF Viewer not Refreshing Properly

Post by jthomas »

Hi Alex,

I was able to use "op.annot.setData" to properly update the UI. No stray line fragments have been spotted so far.

Thanks,

Jared

Code: Select all

public bool UpdateAnnotation(IPXC_Annotation annot, IPXC_AnnotData annotData)
        {
            bool success = true;

            if (annot != null && annotData != null)
            {
                try
                {
                    int nID = IPxv.Str2ID("op.annot.setData", false);
                    IOperation Op = IPxv.CreateOp(nID);
                    ICabNode input = Op.Params.Root[ "Input" ];
                    input.Add().v = annot;
                    ICabNode options = Op.Params.Root[ "Options" ];
                    options[ "NewData" ].v = annotData;
                    Op.Do();
                }
                catch (Exception inner)
                {
                    string errMsg = string.Format(
                        "Failed to update annotation[{0}] within PDF.",
                        annot.Name);
                    logger.Error(errMsg, inner);

                    success = false;
                }
            }
            else
            {
                success = false;
            }

            return success;
        }
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19919
Joined: Mon Jan 12, 2009 8:07 am

Re: PDF Viewer not Refreshing Properly

Post by Stefan - PDF-XChange »

Hi Jared,

Glad to hear you sorted it out!
And thanks for the sample code - I hope it will be useful to other devs as well!

Cheers,
Stefan