Member-only story

Create PDF and print with a WIFI printer in android kotlin.

Harshita Bambure
6 min readJun 16, 2022

--

Today we will learn how to create a pdf file with the itext7 library and after completing a pdf file we will be able to print this pdf using a wifi printer.

In build. gradle we need to add the dependency.

build.Gradle(:app)

implementation 'com.itextpdf:io:7.0.2'
implementation 'com.itextpdf:kernel:7.0.2'
implementation 'com.itextpdf:layout:7.0.2'
implementation 'com.karumi:dexter:6.2.3'

In the android manifest, we need to add permission as well as we need to add file provider.

Android Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.harshita.pdfprintwithwifiprinter">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.PDFprintWithWIFIprinter"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action…

--

--

Harshita Bambure
Harshita Bambure

Written by Harshita Bambure

Android Developer || WomenTech Global Ambassador at WomenTech Network. || Yoga Teacher || Member @WTM .

No responses yet