Create custom PDF page template in Java for Android

Shows how to add custom templates to the new page dialog. Get additional resources by visiting our guide on customizing the PDF editing toolbar in Android.


/*
* Copyright © 2018-2025 PSPDFKit GmbH. All rights reserved.
*
* The PSPDFKit Sample applications are licensed with a modified BSD license.
* Please see License for details. This notice may not be removed from this file.
*/
package com.pspdfkit.catalog.examples.java;
import static com.pspdfkit.catalog.tasks.ExtractAssetTask.extract;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.pspdfkit.catalog.R;
import com.pspdfkit.catalog.SdkExample;
import com.pspdfkit.catalog.examples.java.activities.CustomPageTemplateActivity;
import com.pspdfkit.configuration.activity.PdfActivityConfiguration;
import com.pspdfkit.ui.PdfActivityIntentBuilder;
public class CustomPageTemplatesExample extends SdkExample {
public CustomPageTemplatesExample(Context context) {
super(
context.getString(R.string.customPageTemplateExampleTitle),
context.getString(R.string.customPageTemplateExampleDescription));
}
@Override
public void launchExample(
@NonNull final Context context, @NonNull final PdfActivityConfiguration.Builder configuration) {
// Extract the document from the assets.
extract(ANNOTATIONS_EXAMPLE, getTitle(), context, documentFile -> {
// To start the example create a launch intent using the builder.
final Intent intent = PdfActivityIntentBuilder.fromUri(context, Uri.fromFile(documentFile))
.configuration(configuration.build())
.activityClass(CustomPageTemplateActivity.class)
.build();
context.startActivity(intent);
});
}
}

This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.