Skip to content

Commit

Permalink
#16 Add dummy invoice to generate PDF and reproduce the following bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Md Golam Kibria Emon committed Mar 1, 2021
1 parent c6e9e3e commit b366d96
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 132 deletions.
4 changes: 3 additions & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
/*Comment out the line below if you want to use library from jitpack repo*/
/* implementation 'com.github.Gkemon:XML-to-PDF-generator:2.1'*/
/*
implementation 'com.github.Gkemon:XML-to-PDF-generator:2.2'
*/

implementation 'com.intuit.ssp:ssp-android:1.0.5'
implementation 'com.intuit.sdp:sdp-android:1.0.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void onClick(View v) {
PdfGenerator.getBuilder()
.setContext(MainActivity.this)
.fromViewIDSource()
.fromViewID(MainActivity.this,R.layout.layout_test_invoice,R.id.invoice_layout)
.fromViewID(R.layout.layout_test_invoice,MainActivity.this,R.id.invoice_layout)
.setPageSize(PdfGenerator.PageSize.A4)
.setFileName("TestPDF")
.setFolderName("Test-PDF-folder")
Expand Down
266 changes: 136 additions & 130 deletions sample/src/main/res/layout/layout_test_invoice.xml
Original file line number Diff line number Diff line change
@@ -1,160 +1,166 @@
<LinearLayout android:orientation="vertical"
android:id="@+id/invoice_layout"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="48dp"
xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Our Store Name-->
<TextView
android:layout_gravity="center"
android:id="@+id/shop_name_invoice_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Our shop" />

<!--Our Address-->

<!--Invoice Text-->
<RelativeLayout
android:id="@+id/invoice_text_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/shop_name_invoice_tv">
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/invoice_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="48dp">
<!-- Our Store Name-->
<TextView

android:id="@+id/shop_name_invoice_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="24dp"
android:text="INVOICE" />
android:layout_gravity="center"
android:text="Our shop" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="24dp"
android:text="Customer Copy"
android:textSize="14sp" />
<!--24-->
</RelativeLayout>

<!-- Order Info-->
<LinearLayout
android:id="@+id/order_info_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/invoice_text_layout"
android:layout_marginBottom="32dp"
android:orientation="horizontal"
android:weightSum="2">
<!--Our Address-->

<!--user information-->
<LinearLayout
android:layout_width="0dp"
<!--Invoice Text-->
<RelativeLayout
android:id="@+id/invoice_text_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="3">
android:layout_below="@+id/shop_name_invoice_tv">

<TextView
android:id="@+id/customer_shop_name_tv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Customer shop name" />

<TextView
android:id="@+id/customer_address_tv"

android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="Address" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="24dp"
android:text="INVOICE" />

<TextView
android:id="@+id/customer_phone_tv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="24dp"
android:text="Customer Copy"
android:textSize="14sp" />
<!--24-->
</RelativeLayout>

<!-- Order Info-->
<LinearLayout
android:id="@+id/order_info_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/invoice_text_layout"
android:layout_marginBottom="32dp"
android:orientation="horizontal"
android:weightSum="2">

<!--user information-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Phone number" />
android:orientation="vertical"
android:weightSum="3">

<TextView
android:id="@+id/customer_shop_name_tv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Customer shop name" />

<TextView
android:id="@+id/customer_address_tv"

android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="Address" />

<TextView
android:id="@+id/customer_phone_tv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="Phone number" />

</LinearLayout>

<!--Date Time-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="2">

<TextView
android:id="@+id/customer_order_date_tv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="end"
android:text="Order date" />

<TextView
android:id="@+id/our_delivery_date_tv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:gravity="end"
android:text="Delivery Date" />

</LinearLayout>

</LinearLayout>

<!--Date Time-->
<!--Product List-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/invoice_rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/order_info_layout"
android:background="@color/colorPrimary"
android:padding="1dp" />

<!-- Signature Layout-->
<LinearLayout
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="2">
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginTop="@dimen/_300sdp"
android:gravity="bottom"
android:orientation="horizontal"
android:weightSum="3">

<TextView
android:id="@+id/customer_order_date_tv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:text="Order date" />
android:text="Customer Signature" />

<TextView
android:id="@+id/our_delivery_date_tv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:text="Delivery Date" />
android:gravity="center"
android:text="Prepared By" />

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:text="Authorized Signature" />
</LinearLayout>

</LinearLayout>

<!--Product List-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/invoice_rv"
android:layout_width="match_parent"
android:layout_height="@dimen/_200sdp"
android:layout_below="@+id/order_info_layout"
android:background="@color/colorPrimary"
android:padding="1dp" />

<!-- Signature Layout-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:gravity="bottom"
android:layout_marginTop="48dp"
android:orientation="horizontal"
android:weightSum="3">

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Customer Signature" />

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Prepared By" />

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:text="Authorized Signature" />
</LinearLayout>

</LinearLayout>
</ScrollView>

0 comments on commit b366d96

Please sign in to comment.