Below page would help: programmerworld.co/android/how-to-fetch-data-from-sqlite-database-and-put-that-in-a-pdf-file-in-your-android-app-source-code/ There are lots of videos on my portal on interacting with database through SQL query. Please explore them in the below: programmerworld.co/android/ Cheers Programmer World programmerworld.co -
Just keep adding the pages in your pdfDocument variable. Create multiple pages using PdfDocument.pages type and then add it to the main pdfDocument variable before writing it to the file. For reference, source code of this tutorial is given below: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio Cheers Programmer World programmerworld.co -
Sir , retrieve data from firebase and create pdf in listview items I searched this in GitHub, stack overflow and still I couldn't find the code It will be more helpful If you make that video will be helpful for many
Below link shows steps to create PDF from SQLite database. programmerworld.co/android/how-to-fetch-data-from-sqlite-database-and-put-that-in-a-pdf-file-in-your-android-app-source-code/ Same can be done for Firebase database. For steps on how to get data from Firebase and put it on ListView, refer to the below: programmerworld.co/android/how-to-develop-an-android-app-for-your-retail-business-b2c-using-firebase-database-source-code/ Cheers Programmer World programmerworld.co/ -
I think that's what is shown in the below video. In the below file name (directory path) you have to just change it to your desired path (gallery in your case). private String directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + “/myCamera/”; String file = directory + “3.jpg”; The source code is available at: programmerworld.co/android/how-to-convert-jpg-image-file-into-pdf-file-in-your-android-app-complete-source-code/ Good Luck Programmer World programmerworld.co -
This App uses Canvas concept to write the PDF pages as in the below line of code: myPage.getCanvas() (Refer: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/) The various methods available for the Canvas is mentioned in the below link: developer.android.com/reference/android/graphics/Canvas So, say for example, for tables you may use drawRect method. AFAIK, there is no direct methods to do the complete editing as mentioned in your query. There are some 3rd party libraries but then maintenance of such libraries should be considered while using them. Cheers Programmer World programmerworld.co -
Simply put a " " character. It should insert a new line entry in you document. So, basically in the below line of code, instead of "line" add " ": myPage.getCanvas().drawText(line, x, y, myPaint); I hope this solves your problem. Source code shown in this tutorial can be found in the below link for reference: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/ Cheers Programmer World programmerworld.co -
@@ProgrammerWorld You did the same as you did, but when the long text goes beyond the page When I create a paragraph on an A4 page it continues, but in this form it does not Is there a way to specify text, for example, starting from X25 and ending at y250?
@@ProgrammerWorld You are here, x10 is twice the text that starts from left to right and y 25 text starts from top to bottom and the paper size is 300 width and 600 cm. Here I need to stop the text at 290 wide and 590 long How do I do it?
Hi, There is a string data in the database. The length of this data varies. How do we fit this string data into pdf document according to a certain width and height? There should be more than one page depending on the size of the data. How can i do it?
Just check the total length of the string received from the database. If it is longer than one page's content (depending on the page length and width) then split the text into multiple pages. To create multiple pages, just keep adding the pages as shown in the below lines of code: PdfDocument.Page myPage1 = myPdfDocument.startPage(myPageInfo); // Write into myPage1 myPdfDocument.finishPage(myPage1); PdfDocument.Page myPage2 = myPdfDocument.startPage(myPageInfo); // Write into myPage2 myPdfDocument.finishPage(myPage2); . . . PdfDocument.Page myPagen = myPdfDocument.startPage(myPageInfo); // Write into myPagen myPdfDocument.finishPage(myPagen); For reference, the complete source code shown in this tutorial is also shared in the below link: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/ Cheers Programmer World programmerworld.co -
As per the code shown in this video, the file gets created at the below: String myFilePath = Environment.getExternalStorageDirectory().getPath() + “/myPDFFile.pdf”; So, the location of the file should be in the root folder of your phone's storage, for emulator it is named as - sdk_gphone64_x86_64. But this name differ for your device. The easiest way to navigate to this folder will be to go to the download folder of your device and then go one level up in the directory structure. For reference, details shown in this video is also shared in the below link: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/ Cheers Programmer World programmerworld.co -
It will work for multiple pages also. Simply keep adding the pages in the myPdfDocument as shown below: // Adding 1st page: PdfDocument.PageInfo myPageInfo = new PdfDocument.PageInfo.Builder(300,600,1).create(); PdfDocument.Page myPage = myPdfDocument.startPage(myPageInfo); Paint myPaint = new Paint(); String myString = myEditText.getText().toString(); int x = 10, y=25; for (String line:myString.split(“ ”)){ myPage.getCanvas().drawText(line, x, y, myPaint); y+=myPaint.descent()-myPaint.ascent(); } myPdfDocument.finishPage(myPage); /****************************************************/ // Repeating the code for 2nd page: PdfDocument.PageInfo myPageInfo2 = new PdfDocument.PageInfo.Builder(300,600,2).create(); PdfDocument.Page myPage2 = myPdfDocument.startPage(myPageInfo2); Paint myPaint2 = new Paint(); String myString2 = "Some Text" int x = 10, y=25; for (String line:myString2.split(“ ”)){ myPage2.getCanvas().drawText(line, x, y, myPaint2); y+=myPaint2.descent()-myPaint2.ascent(); } myPdfDocument.finishPage(myPage2); /****************************************************/ // Repeat further for 3rd page .... and so on. So, the above should help in creating a multiple page pdf. For reference, complete source code shown in this project is available in the below link: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/ Cheers Programmer World programmerworld.co/ -
Hello, I did exactly as in the video. Everything works properly on the Simulator, but on the phone I can't open the pdf file, it shows an error: "Cannot display PDF (pdfname.pdf is of invalid format)"
It should work on the phone also. Please check for your the source code of this project at the below link: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/ Cheers Programmer World programmerworld.co -
You should use paint settings for your page. The Paint class holds the style and color information about how to draw geometries, text and bitmaps. More options of paint can be seen in below Android developer portal: developer.android.com/reference/android/graphics/Paint.html
Yes, it is possible to use Firebase database for storing files such as pdf. You can watch my below video which explains the steps to create your end to end encryption chat App using Firebase database: ua-cam.com/video/bVXT_AkHIEQ/v-deo.html Though in my tutorial it shows only text interaction with Firebase but similar steps can be used for files. I will try to create another video to show these steps. Thanks for bringing this up. Cheers Programmer World programmerworld.co -
There could be various reasons for the App to not work on the phone. Check whether required permissions are given to the App in the phone. Also check whether the path to which the file is being written exists and you have write permission on that. Good Luck Programmer World programmerworld.co -
I think what you are looking for is explained in my below video tutorial: ua-cam.com/video/lOnBeHaRNZc/v-deo.html This video explains how to create your PDF reader Android App. I hope it is useful. Let me know if it helped. Cheers Programmer World programmerworld.co -
I think, you can simply add more edit texts in your layout and in your Java code collect the texts from all the edit texts in one single string and then use it to write to your PDF. Cheers Programmer World programmerworld.co -
It should work in Android Studio 4.1 version also as long as the chosen API level is 19 and above. It is because this App uses PdfDocument Class to create the PDF. As this class was Added in API level 19 of Android which is basically Android 4.4(Kitkat), so API level of 19 and above should be chosen while creating this App. Cheers Programmer World programmerworld.co -
@@ProgrammerWorld I've selected API level 30. but still doesn't work, WRITE_EXTERNAL_STORAGE no longer provides write access when targeting Android 11+, even when using requestLegacyExternalstorage. then what should I do?
sir it did'nt worked i am having a error in logcat which says : java.io.FileNotFoundException: /storage/emulated/0/text_recognition.pdf: open failed: EACCES (Permission denied) the device i am using does not have a sdcard inserted can you please help me i want to save it in my specified folder so that it is available from the storage also.
Either you do not have permission to write to an external storage or as you mentioned the external storage does not exists. You can always write your file to another location such as download folder using: Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); For complete source code of this tutorial, you can refer to the below link: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/ Hope it helps. Good Luck Programmer World programmerworld.co -
@@ProgrammerWorld I am using android 10 and the android documentation says that getExternalStoragePublicDirectory() is deprecated in api29 and the other methods like getExternalFilesDir() it stores the file in storage/android/data/domain_name/files section but i want to store it at storage/download can you tell me how to do that.
@@aniketkushwaha1747 Even if it is deprecated, it will work. For alternate APIs, please check Android developer portal. They will definitely suggest workaround. Good Luck Programmer World programmerworld.co -
Sir, I understand everything, but please can you tell me the code e.g. while reading book on PDF and you cut it and turn it one again and then still remain the chapter you've stopped reading. Thanks for sharing it to me.
I assume that you are looking for a pdf reader App here. How to create a pdf reader App is explained in the below video: ua-cam.com/video/lOnBeHaRNZc/v-deo.html Now, in this reader App, if you want to read any specific page then just set the page number in the below line of code: stringParser = PdfTextExtractor.getTextFromPage(pdfReader, 1).trim(); The complete source code of this App can be found in the below link: programmerworld.co/android/how-to-create-your-pdf-reader-android-app-complete-source-code/ Cheers Programmer World programmerworld.co -
Sir, please that place you add only number 1 I just want to see my last page if I resume the app. How can I write that code in order not see only number 1 page. Thanks
I assume the error is being thrown from the below catch part of the code: try { myPdfDocument.writeTo(new FileOutputStream(myFile)); } catch (Exception e){ e.printStackTrace(); myEditText.setText(“ERROR”); } [The above piece code is taken from: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/] Now, the most likely reason for this ERROR will be that the file in which you are trying is either does not exists or there is some issue with the myFile variable accessing the correct file. To resolve this, I will suggest to try with some other filename and in some other location like App's data folder, one such example is shown in the below: programmerworld.co/android/how-to-create-microsoft-word-document-docx-file-from-your-android-app/ Even then the issue is there then try to debug the code and check the exception thrown. If you can copy the value of e (Exception) thrown in the catch part here, we can try to check on that. Cheers Programmer World programmerworld.co -
I do not have any video which shows the steps to share the file. However, if interested, you can watch my below video which shows how you can navigate to another App such gmaill, whatsapp, Facebook, etc. ua-cam.com/video/XvH748sImco/v-deo.html Good Luck Programmer World programmerworld.co -
Below details should help in sharing the file through other Apps, such as Email client, WhatsApp, etc.: programmerworld.co/android/how-to-share-file-or-text-on-gmail-whatsapp-sms-bluetooth-from-your-android-app-share-button/ Cheers Programmer World programmerworld.co -
I think that should be possible. Just check setTextLocale option in the style of the PDF page you are creating. They support all major languages and locale of the world. Refer to the link below: developer.android.com/reference/android/graphics/Paint#setTextLocale(java.util.Locale) By the way complete source code of this tutorial is shared at: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/ Hope this is useful.
What is the error you are observing? Can you please elaborate? By the way for reference, complete source code shown in this project is available in the below link as well: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/ Cheers Programmer World programmerworld.co/ -
Theoretically, this should not happen as the size of App is independent of the files it creates. In practice, it might be happening because of cache memory. Certain Apps in Android keeps lots of information in cache. So, it depends upon the API you have used to add the PDFs that what all information it has saved in cache. Killing the App from task manager is one of the easiest way to clean the cache. Cheers Programmer World programmerworld.co -
Any error you are getting? Try to create the file in some other folders such as downloads or image folder. Check if you have the "write to external storage" permission for this App. Good Luck Programmer World programmerworld.co -
why i always get error in PdfDocument The error is: Call requires API level 19(current min is 14):new android.graphics.PdfDocument can you help me for fix it sir?
Because your minimum SDK is set to 14. Please go to your build.gradle file (App level and not project level) and change the minSdkVersion attribure to 19 in this file. Please make sure to sync the gradle file when prompted after this change to have the changes reflected in your project. Good Luck Programmer World programmerworld.co -
Have you used any of pdf library... Or can it convert hindi text into pdf.format..🤔
Thank you. This very useful.
I want to print sql data with the button click. Can you you help me?
Below page would help:
programmerworld.co/android/how-to-fetch-data-from-sqlite-database-and-put-that-in-a-pdf-file-in-your-android-app-source-code/
There are lots of videos on my portal on interacting with database through SQL query. Please explore them in the below:
programmerworld.co/android/
Cheers
Programmer World
programmerworld.co
-
Thank you it was very helpful and it worked.
vedio is good but also zoom the code and type
Thanks for the suggestion. Yes, from next video we will use zoom feature to show the texts more clearly.
Cheers
Programmer World
programmerworld.co
-
this is help full thank you
uses or overrides a deprecated API.
Recompile with -Xlint:deprecation for details.
Thank you sir this video is very usefull for me. But i want to know if my first page is full how to go next page. Please help sir.
Just keep adding the pages in your pdfDocument variable. Create multiple pages using PdfDocument.pages type and then add it to the main pdfDocument variable before writing it to the file.
For reference, source code of this tutorial is given below:
programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio
Cheers
Programmer World
programmerworld.co
-
Sir , retrieve data from firebase and create pdf in listview items
I searched this in GitHub, stack overflow and still I couldn't find the code
It will be more helpful
If you make that video will be helpful for many
Below link shows steps to create PDF from SQLite database.
programmerworld.co/android/how-to-fetch-data-from-sqlite-database-and-put-that-in-a-pdf-file-in-your-android-app-source-code/
Same can be done for Firebase database. For steps on how to get data from Firebase and put it on ListView, refer to the below:
programmerworld.co/android/how-to-develop-an-android-app-for-your-retail-business-b2c-using-firebase-database-source-code/
Cheers
Programmer World
programmerworld.co/
-
Hello, is there a way to do this, but with an image that is selected from the gallery and not previously loaded on a route?
I think that's what is shown in the below video. In the below file name (directory path) you have to just change it to your desired path (gallery in your case).
private String directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + “/myCamera/”;
String file = directory + “3.jpg”;
The source code is available at:
programmerworld.co/android/how-to-convert-jpg-image-file-into-pdf-file-in-your-android-app-complete-source-code/
Good Luck
Programmer World
programmerworld.co
-
How to create tables, nested tables, header and footer by using this inbuild pdf library?
This App uses Canvas concept to write the PDF pages as in the below line of code:
myPage.getCanvas()
(Refer: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/)
The various methods available for the Canvas is mentioned in the below link:
developer.android.com/reference/android/graphics/Canvas
So, say for example, for tables you may use drawRect method. AFAIK, there is no direct methods to do the complete editing as mentioned in your query. There are some 3rd party libraries but then maintenance of such libraries should be considered while using them.
Cheers
Programmer World
programmerworld.co
-
good job
When writing long text that goes beyond the page boundaries, how do I make it drop a line?
Simply put a "
" character. It should insert a new line entry in you document.
So, basically in the below line of code, instead of "line" add "
":
myPage.getCanvas().drawText(line, x, y, myPaint);
I hope this solves your problem.
Source code shown in this tutorial can be found in the below link for reference:
programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/
Cheers
Programmer World
programmerworld.co
-
@@ProgrammerWorld You did the same as you did, but when the long text goes beyond the page
When I create a paragraph on an A4 page it continues, but in this form it does not
Is there a way to specify text, for example, starting from X25 and ending at y250?
@@ProgrammerWorld You are here, x10 is twice the text that starts from left to right and y 25 text starts from top to bottom and the paper size is 300 width and 600 cm.
Here I need to stop the text at 290 wide and 590 long
How do I do it?
How to open the PDF file automatically after create it?
It is possible to put images from camera on pdf file too?
You should refer to my below video in this regard:
ua-cam.com/video/sOKV3iHl5aM/v-deo.html
I hope this video is helpful.
Hi,
There is a string data in the database. The length of this data varies. How do we fit this string data into pdf document according to a certain width and height? There should be more than one page depending on the size of the data. How can i do it?
Just check the total length of the string received from the database. If it is longer than one page's content (depending on the page length and width) then split the text into multiple pages.
To create multiple pages, just keep adding the pages as shown in the below lines of code:
PdfDocument.Page myPage1 = myPdfDocument.startPage(myPageInfo);
// Write into myPage1
myPdfDocument.finishPage(myPage1);
PdfDocument.Page myPage2 = myPdfDocument.startPage(myPageInfo);
// Write into myPage2
myPdfDocument.finishPage(myPage2);
. . .
PdfDocument.Page myPagen = myPdfDocument.startPage(myPageInfo);
// Write into myPagen
myPdfDocument.finishPage(myPagen);
For reference, the complete source code shown in this tutorial is also shared in the below link:
programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/
Cheers
Programmer World
programmerworld.co
-
@@ProgrammerWorld Thank you for response. How can I establish the relationship between page height and width and string length?
Please give tutorial on how to convert pdf to word in android studio
Thanks for the suggestion. Will try to make a video on this topic.
Cheers
Programmer World
programmerworld.co
-
I run in my mobile i cant see where is the pdf or it havent been created! please help me
As per the code shown in this video, the file gets created at the below:
String myFilePath = Environment.getExternalStorageDirectory().getPath() + “/myPDFFile.pdf”;
So, the location of the file should be in the root folder of your phone's storage, for emulator it is named as - sdk_gphone64_x86_64. But this name differ for your device. The easiest way to navigate to this folder will be to go to the download folder of your device and then go one level up in the directory structure.
For reference, details shown in this video is also shared in the below link:
programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/
Cheers
Programmer World
programmerworld.co
-
Its not working for text more than 1 pages. How do i make it??
It will work for multiple pages also.
Simply keep adding the pages in the myPdfDocument as shown below:
// Adding 1st page:
PdfDocument.PageInfo myPageInfo = new PdfDocument.PageInfo.Builder(300,600,1).create();
PdfDocument.Page myPage = myPdfDocument.startPage(myPageInfo);
Paint myPaint = new Paint();
String myString = myEditText.getText().toString();
int x = 10, y=25;
for (String line:myString.split(“
”)){
myPage.getCanvas().drawText(line, x, y, myPaint);
y+=myPaint.descent()-myPaint.ascent();
}
myPdfDocument.finishPage(myPage);
/****************************************************/
// Repeating the code for 2nd page:
PdfDocument.PageInfo myPageInfo2 = new PdfDocument.PageInfo.Builder(300,600,2).create();
PdfDocument.Page myPage2 = myPdfDocument.startPage(myPageInfo2);
Paint myPaint2 = new Paint();
String myString2 = "Some Text"
int x = 10, y=25;
for (String line:myString2.split(“
”)){
myPage2.getCanvas().drawText(line, x, y, myPaint2);
y+=myPaint2.descent()-myPaint2.ascent();
}
myPdfDocument.finishPage(myPage2);
/****************************************************/
// Repeat further for 3rd page
.... and so on.
So, the above should help in creating a multiple page pdf.
For reference, complete source code shown in this project is available in the below link:
programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/
Cheers
Programmer World
programmerworld.co/
-
Hello, I did exactly as in the video. Everything works properly on the Simulator, but on the phone I can't open the pdf file,
it shows an error: "Cannot display PDF (pdfname.pdf is of invalid format)"
It should work on the phone also. Please check for your the source code of this project at the below link:
programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/
Cheers
Programmer World
programmerworld.co
-
How can i change the text size and maybe make some text bold or italic?
You should use paint settings for your page.
The Paint class holds the style and color information about how to draw geometries, text and bitmaps.
More options of paint can be seen in below Android developer portal:
developer.android.com/reference/android/graphics/Paint.html
It is possible to load pdf file to firebase?
Yes, it is possible to use Firebase database for storing files such as pdf. You can watch my below video which explains the steps to create your end to end encryption chat App using Firebase database:
ua-cam.com/video/bVXT_AkHIEQ/v-deo.html
Though in my tutorial it shows only text interaction with Firebase but similar steps can be used for files. I will try to create another video to show these steps.
Thanks for bringing this up.
Cheers
Programmer World
programmerworld.co
-
Hello, I did exactly as in the video. Everything works properly on the Simulator, but not on the phone. Why?
There could be various reasons for the App to not work on the phone.
Check whether required permissions are given to the App in the phone. Also check whether the path to which the file is being written exists and you have write permission on that.
Good Luck
Programmer World
programmerworld.co
-
sir if i want to extract text from pdf in android studio what should i do?
I think what you are looking for is explained in my below video tutorial:
ua-cam.com/video/lOnBeHaRNZc/v-deo.html
This video explains how to create your PDF reader Android App.
I hope it is useful. Let me know if it helped.
Cheers
Programmer World
programmerworld.co
-
can you please demonstrate how to fetch data from the sqlite database and put that in the pdf?
You can watch below video for the same:
ua-cam.com/video/uqyY7jM2cZI/v-deo.html
-
how to use more edit text to creat pdf file?
I think, you can simply add more edit texts in your layout and in your Java code collect the texts from all the edit texts in one single string and then use it to write to your PDF.
Cheers
Programmer World
programmerworld.co
-
@@ProgrammerWorld done, i can add many text haha.. thanks for your tutorial dude.. wish all u the best 👍
Why doesn't it work in my android studio v4.1?
It should work in Android Studio 4.1 version also as long as the chosen API level is 19 and above.
It is because this App uses PdfDocument Class to create the PDF. As this class was Added in API level 19 of Android which is basically Android 4.4(Kitkat), so API level of 19 and above should be chosen while creating this App.
Cheers
Programmer World
programmerworld.co
-
@@ProgrammerWorld I've selected API level 30. but still doesn't work, WRITE_EXTERNAL_STORAGE no longer provides write access when targeting Android 11+, even when using requestLegacyExternalstorage. then what should I do?
sir it did'nt worked i am having a error in logcat which says :
java.io.FileNotFoundException: /storage/emulated/0/text_recognition.pdf: open failed: EACCES (Permission denied)
the device i am using does not have a sdcard inserted can you please help me i want to save it in my specified folder so that it is available from the storage also.
Either you do not have permission to write to an external storage or as you mentioned the external storage does not exists. You can always write your file to another location such as download folder using: Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
For complete source code of this tutorial, you can refer to the below link:
programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/
Hope it helps.
Good Luck
Programmer World
programmerworld.co
-
@@ProgrammerWorld
I am using android 10 and the android documentation says that getExternalStoragePublicDirectory() is deprecated in api29 and the other methods like getExternalFilesDir() it stores the file in storage/android/data/domain_name/files section but i want to store it at storage/download can you tell me how to do that.
@@aniketkushwaha1747 Even if it is deprecated, it will work. For alternate APIs, please check Android developer portal. They will definitely suggest workaround.
Good Luck
Programmer World
programmerworld.co
-
sir it did'nt worked i am having a error
Sir, I understand everything, but please can you tell me the code e.g. while reading book on PDF and you cut it and turn it one again and then still remain the chapter you've stopped reading. Thanks for sharing it to me.
I assume that you are looking for a pdf reader App here. How to create a pdf reader App is explained in the below video:
ua-cam.com/video/lOnBeHaRNZc/v-deo.html
Now, in this reader App, if you want to read any specific page then just set the page number in the below line of code:
stringParser = PdfTextExtractor.getTextFromPage(pdfReader, 1).trim();
The complete source code of this App can be found in the below link:
programmerworld.co/android/how-to-create-your-pdf-reader-android-app-complete-source-code/
Cheers
Programmer World
programmerworld.co
-
Thanks. You're one of the best.
Sir, please that place you add only number 1 I just want to see my last page if I resume the app. How can I write that code in order not see only number 1 page. Thanks
i will show error, when I click on the button, on text view error is printing and pdf is not generating
I assume the error is being thrown from the below catch part of the code:
try {
myPdfDocument.writeTo(new FileOutputStream(myFile));
}
catch (Exception e){
e.printStackTrace();
myEditText.setText(“ERROR”);
}
[The above piece code is taken from: programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/]
Now, the most likely reason for this ERROR will be that the file in which you are trying is either does not exists or there is some issue with the myFile variable accessing the correct file.
To resolve this, I will suggest to try with some other filename and in some other location like App's data folder, one such example is shown in the below:
programmerworld.co/android/how-to-create-microsoft-word-document-docx-file-from-your-android-app/
Even then the issue is there then try to debug the code and check the exception thrown. If you can copy the value of e (Exception) thrown in the catch part here, we can try to check on that.
Cheers
Programmer World
programmerworld.co
-
is application ko share ka batton kase lagaye sir plz bataye
I do not have any video which shows the steps to share the file. However, if interested, you can watch my below video which shows how you can navigate to another App such gmaill, whatsapp, Facebook, etc.
ua-cam.com/video/XvH748sImco/v-deo.html
Good Luck
Programmer World
programmerworld.co
-
sir how to share pdf f iles programatically kindly help
Below details should help in sharing the file through other Apps, such as Email client, WhatsApp, etc.:
programmerworld.co/android/how-to-share-file-or-text-on-gmail-whatsapp-sms-bluetooth-from-your-android-app-share-button/
Cheers
Programmer World
programmerworld.co
-
sir, thank you for your valuable tutorials.
Can I make pdf in bangla text????
I think that should be possible. Just check setTextLocale option in the style of the PDF page you are creating. They support all major languages and locale of the world. Refer to the link below:
developer.android.com/reference/android/graphics/Paint#setTextLocale(java.util.Locale)
By the way complete source code of this tutorial is shared at:
programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/
Hope this is useful.
Razu bro does it work for bagla language?
@@anikbiswas6775 yes, bro.
razu vai,ki change kora lagbe code e?naki ja ache tai hobe?
@@anikbiswas6775 myPaint.setTextLocal(new Local ("bn"));
it is showing error what should i do?
What is the error you are observing? Can you please elaborate?
By the way for reference, complete source code shown in this project is available in the below link as well:
programmerworld.co/android/how-to-create-pdf-file-in-your-android-app-complete-source-code-using-android-studio/
Cheers
Programmer World
programmerworld.co/
-
hi i add 2 pdfs in my app and app size become 20 mb but my pdf size is less then 500 KB
WHY this happen?
Theoretically, this should not happen as the size of App is independent of the files it creates.
In practice, it might be happening because of cache memory. Certain Apps in Android keeps lots of information in cache. So, it depends upon the API you have used to add the PDFs that what all information it has saved in cache.
Killing the App from task manager is one of the easiest way to clean the cache.
Cheers
Programmer World
programmerworld.co
-
image se pdf file kaise bnaye
Refer below link:
programmerworld.co/android/how-to-convert-jpg-image-file-into-pdf-file-in-your-android-app-complete-source-code/
Cheers
Programmer World
programmerworld.co
-
It doesn’t work for me i dont find à pdf on the files
Any error you are getting?
Try to create the file in some other folders such as downloads or image folder. Check if you have the "write to external storage" permission for this App.
Good Luck
Programmer World
programmerworld.co
-
Me too.
why i always get error in PdfDocument
The error is:
Call requires API level 19(current min is 14):new android.graphics.PdfDocument
can you help me for fix it sir?
Because your minimum SDK is set to 14.
Please go to your build.gradle file (App level and not project level) and change the minSdkVersion attribure to 19 in this file. Please make sure to sync the gradle file when prompted after this change to have the changes reflected in your project.
Good Luck
Programmer World
programmerworld.co
-
this code does not work.
For latest version of Android, please use code from below video:
ua-cam.com/video/RcxtWbrT5BI/v-deo.html
Cheers
Programmer World
programmerworld.co
-