ComPDF React Native - v3.0.0
    Preparing search index...

    Class CPDFPage

    CPDFPage The CPDFPage class represents a page in a PDF document. It provides methods to retrieve annotations and form widgets present on the page.

    // Get the first page
    const pageIndex = 0;
    const cpdfPage : CPDFPage = pdfReaderRef?.current?._pdfDocument.pageAtIndex(pageIndex);
    Index

    Constructors

    • Parameters

      • viewerRef: any
      • pageIndex: number

      Returns CPDFPage

    Methods

    • Retrieves all text on the current page.

      Returns Promise<string>

      const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(0);
      const text = await page?.getAllText();
    • Retrieves text inside the specified rectangle on the current page.

      Parameters

      • rect: CPDFRectF

        The rectangle in page coordinates.

      Returns Promise<string>

    • Retrieves text for a line returned by [getTextLines].

      Parameters

      Returns Promise<string>

    • Retrieves all annotations on the current page.

      This method fetches all annotations present on the current page of the PDF document and returns a list of corresponding CPDFAnnotation instances.

      Returns Promise<CPDFAnnotation[]>

      A promise that resolves with all annotations on the current page, or an empty array if retrieval fails.

      const pageIndex = 0;
      const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(pageIndex);
      const annotations = await page?.getAnnotations();
    • Retrieves all form widgets on the current page.

      This method fetches all form widgets available on the current page of the PDF document and returns a list of corresponding CPDFWidget instances.

      Returns Promise<CPDFWidget[]>

      A promise that resolves to an array of CPDFWidget instances representing form widgets on the current page. Returns an empty array if retrieval fails. Rejects with an error if the native view reference is unavailable.

      const pageIndex = 0;
      const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(pageIndex);
      const widgets = await page?.getWidgets();
      • CPDFWidget - Base class for all form widgets
      • CPDFTextWidget - Text input field widget
      • CPDFSignatureWidget - Signature widget
      • CPDFRadiobuttonWidget - Radio button widget
      • CPDFPushbuttonWidget - Button widget
      • CPDFListboxWidget - List box widget
      • CPDFComboboxWidget - Combo box widget
      • CPDFCheckboxWidget - Checkbox widget
    • Removes an annotation from the current page.

      Parameters

      Returns Promise<boolean>

      const pageIndex = 0;
      const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(pageIndex);
      const annotations = await page?.getAnnotations();
      const annotationToRemove = annotations[0];
      await page?.removeAnnotation(annotationToRemove);
    • Removes a form widget from the current page.

      Parameters

      Returns Promise<boolean>

      A promise that resolves to true when the widget is removed.

      const pageIndex = 0;
      const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(pageIndex);
      const widgets = await page?.getWidgets();
      const widgetToRemove = widgets[0];
      await page?.removeWidget(widgetToRemove);

      CPDFWidget - Base class for all form widgets

    • Gets the rotation angle of the current page.

      Returns Promise<number>

      A promise that resolves to the page rotation in degrees.

      const pageIndex = 0;
      const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(pageIndex);
      const rotation = await page?.getRotation();
    • Sets the rotation angle of the current page.

      Parameters

      • rotation: number

        The rotation angle in degrees (0, 90, 180, 270). 360 is treated as 0.

      Returns Promise<boolean>

      A promise that resolves to true when the rotation is applied.

      const pageIndex = 0;
      const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(pageIndex);
      const success = await page?.setRotation(90);

    Properties

    pageIndex: number