Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I add Footer to every page #10

Closed
meysamhadigheh opened this issue Feb 3, 2021 · 3 comments
Closed

How can I add Footer to every page #10

meysamhadigheh opened this issue Feb 3, 2021 · 3 comments
Assignees

Comments

@meysamhadigheh
Copy link

No description provided.

@tejpratap46 tejpratap46 self-assigned this Feb 3, 2021
@tejpratap46
Copy link
Owner

It is not currently possible as it had some complications implementing it. Will sure look into possibilities of adding it again.

@tejpratap46
Copy link
Owner

From version 2.0, you have to override getFooterView(pageIndex) to give Footer for page

@Override
protected PDFFooterView getFooterView(int pageIndex) {
    PDFFooterView footerView = new PDFFooterView(getApplicationContext());

    PDFTextView pdfTextViewPage = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.SMALL);
    pdfTextViewPage.setText(String.format(Locale.getDefault(), "Page: %d", pageIndex + 1));
    pdfTextViewPage.setLayout(new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT, 0));
    pdfTextViewPage.getView().setGravity(Gravity.CENTER_HORIZONTAL);

    footerView.addView(pdfTextViewPage);

    return footerView;
}

@meysamhadigheh
Copy link
Author

From version 2.0, you have to override getFooterView(pageIndex) to give Footer for page

@Override
protected PDFFooterView getFooterView(int pageIndex) {
    PDFFooterView footerView = new PDFFooterView(getApplicationContext());

    PDFTextView pdfTextViewPage = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.SMALL);
    pdfTextViewPage.setText(String.format(Locale.getDefault(), "Page: %d", pageIndex + 1));
    pdfTextViewPage.setLayout(new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT, 0));
    pdfTextViewPage.getView().setGravity(Gravity.CENTER_HORIZONTAL);

    footerView.addView(pdfTextViewPage);

    return footerView;
}

Thanks a lot 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants