Xamarin Forms PDFTron Search Text

Product:PDFTron

Product Version:Trial

Cannot implement Search on Viewer

As your samples, pdfviewer and pdfviewer renderer classes created. open pdf file in a control works fine. but can not add search button on view and can not search text. tried many ways to show but nothing changed.

1 Like

I will need a little more information to assist you. Can you tell me which SDK package you are using, Xamarin.Android or Xamarin .iOS, and the PDFNet SDK version number you are working with.

1 Like

PDFTron.iOS and PDFTron .iOS.Tools (Xamarin.iOS Nuget Package) both versions 10.3.0. not sure about PDFNet but PDFNetiOS.dll version is 0.0.0.0 (from debug folder).

var textSearchViewController = new PTTextSearchViewController(mPdfViewCtrl);
textSearchViewController.SearchViewControllerDidDismiss += (sender, e) =>
{

        };
        var navigationController = new UINavigationController(textSearchViewController);

        navigationController.ModalPresentationStyle = UIModalPresentationStyle.Popover;
        navigationController.PopoverPresentationController.BarButtonItem = searchButton;

        UIWindow window = UIApplication.SharedApplication.KeyWindow;
        UIViewController vc = window.RootViewController;

        while (vc.PresentedViewController != null)
            vc = vc.PresentedViewController;

        vc.PresentViewController(navigationController, true, null);

        NativeView.AddSubview(mPdfViewCtrl);

        NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[]
        {
            documentController.View.LeadingAnchor.ConstraintEqualTo(this.NativeView.LeadingAnchor),
            documentController.View.WidthAnchor.ConstraintEqualTo(this.NativeView.WidthAnchor),
            documentController.View.BottomAnchor.ConstraintEqualTo(this.NativeView.BottomAnchor)
        });

        NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[]
        {
            mSearchView.View.LeadingAnchor.ConstraintEqualTo(this.NativeView.LeadingAnchor),
            mSearchView.View.WidthAnchor.ConstraintEqualTo(this.NativeView.WidthAnchor),
            mSearchView.View.BottomAnchor.ConstraintEqualTo(this.NativeView.TopAnchor)
        });

above code added in SetupUserInterface() function. I want to show like your PTDocumentController document 7.Text Search button. this code shows popup from left up corner but this time pdf can not be viewed.

1 Like

Hi @busranerse,

Are you able to share some more information about the exact issue you’re seeing?
Could you share a video showing the problem as well as a description of the expected behaviour?

1 Like