Comments (14)
@hucong730 Do you have the original pdf file?
from pdfbox-android.
I got the same issue, while opening a pdf with password. I didn't get that with a pdf without password.
`val inputStream: InputStream = FileInputStream(file)
// Load in an already created PDF
val document: PDDocument = PDDocument.load(inputStream, "azerty")
// Create a renderer for the document
val renderer = PDFRenderer(document)
// Render the image to an RGB Bitmap
val pageImage = renderer.renderImage(0, 1F, ImageType.RGB)
Handler(Looper.getMainLooper()).post {
if(pageImage != null){
binding.pwdPDFView.setImageBitmap(pageImage)
} else{
Toast.makeText(requireContext(), "Error BITMAP happened", Toast.LENGTH_SHORT).show()
}
}
// Your code to password protect the document will go here
document.close()`
from pdfbox-android.
@MikaReesu I can try to solve it, can you provide the PDF file?
from pdfbox-android.
from pdfbox-android.
Here the document : Password : azerty
…
On Fri, Feb 2, 2024, 10:10 LangLord @.> wrote: @MikaReesu https://github.com/MikaReesu I can try to solve it, can you provide the PDF file? — Reply to this email directly, view it on GitHub <#557 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATBTBWVSJHS4CN7WQ3BR2GTYRSUPJAVCNFSM6AAAAABB5ZLGHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRTGM3TQMRYHA . You are receiving this because you were mentioned.Message ID: @.>
No pdf found
from pdfbox-android.
Didn't work from Gmail here the pdf.
single_password.pdf
from pdfbox-android.
Didn't work from Gmail here the pdf. single_password.pdf
I'm getting a normal rendering here.
from pdfbox-android.
I'm getting a normal rendering here.Didn't work from Gmail here the pdf. single_password.pdf
`try {
// Load in an already created PDF
// PDDocument document = PDDocument.load(new File(path),"hi");
PDDocument document = PDDocument.load(assetManager.open("single_password.pdf"), "azerty");
// Create a renderer for the document
PDFRenderer renderer = new PDFRenderer(document);
// Render the image to an RGB Bitmap
pageImage = renderer.renderImage(0, 1, ImageType.RGB);
// Save the render result to an image
String path2 = root.getAbsolutePath() + "/decrypt_render.jpg";
File renderFile = new File(path2);
FileOutputStream fileOut = new FileOutputStream(renderFile);
pageImage.compress(Bitmap.CompressFormat.JPEG, 100, fileOut);
fileOut.close();
tv.setText("Successfully rendered image to " + path2);
// Optional: display the render result on screen
displayRenderedImage();
} catch (IOException e) {
Log.e("PdfBox-Android-Sample", "Exception thrown while rendering file", e);
}`
from pdfbox-android.
use :
implementation "com.tom-roush:pdfbox-android:2.0.27.0" , render error
use:
implementation project(':library') (source code) , render fine
from pdfbox-android.
What is that?
implementation project(':library') (source code) , render fine
It doesn't seem to be correct. If it's in gradle it leads to an error :
Project with path ':library' could not be found in project ':app'.
It will be a good idea to put the code directly in Kotlin and also directly in the readme.
I tried with a FILE and an InputStream but it was rendered like I previously showed. Not with all the letters of the text.
About your assetManager, how to initialise it ? In the sample I see a getAssets(), but I didn't find the function in the sample.
val assetManager: AssetManager = getAssets()
This gives an unresolved reference.
I'm getting the PDF from a DocumentPicker, so I can get the path with file.path. Not sure if that is gonna work with all the versions of Android.
from pdfbox-android.
For library, I just found where to add, but why do I need to add the library that way?
implementation "com.tom-roush:pdfbox-android:2.0.27.0"
This should contain everything needed, normally.
Is there a particular reason why, we have to do add the folder library manually?
from pdfbox-android.
What is that?
implementation project(':library') (source code) , render fine
It doesn't seem to be correct. If it's in gradle it leads to an error :Project with path ':library' could not be found in project ':app'.
It will be a good idea to put the code directly in Kotlin and also directly in the readme.I tried with a FILE and an InputStream but it was rendered like I previously showed. Not with all the letters of the text.
About your assetManager, how to initialise it ? In the sample I see a getAssets(), but I didn't find the function in the sample.
val assetManager: AssetManager = getAssets()
This gives an unresolved reference.I'm getting the PDF from a DocumentPicker, so I can get the path with file.path. Not sure if that is gonna work with all the versions of Android.
from pdfbox-android.
For library, I just found where to add, but why do I need to add the library that way?对于库,我刚刚找到了要添加的位置,但为什么我需要以这种方式添加库?
implementation "com.tom-roush:pdfbox-android:2.0.27.0"实现“com.tom-roush:pdfbox-android:2.0.27.0”
This should contain everything needed, normally.通常,这应该包含所需的一切。
Is there a particular reason why, we have to do add the folder library manually?有没有特别的原因,我们必须手动添加文件夹库?
I understand that "com.tom-roush:pdfbox-android:2.0.27.0" is buggy, you can build a new aar based on the master branch of "PDFBox-Android".
from pdfbox-android.
Thank you. I'll be looking for another library. Seems too risky for production app.
from pdfbox-android.
Related Issues (20)
- PDFTextStripper.getText misses some characters from a PDF file HOT 1
- java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.InputStream.close()' on a null object reference HOT 1
- Give the possability to use a Cross/X to check a PDCheckBox HOT 1
- PDFontDescriptor font leading = 0
- Compressed text is not rendered properly.
- I think I fixed a text rendering bug. HOT 2
- PdfBox-Android: No valid object at given location 9409516PdfBox-Android: No valid object at given location 9409516 HOT 17
- The Problem of Password Parameter in Load Method
- Bengali broken word. How to solve?
- How to modify the text size in PDF files
- free doc viewer support view word excel ppt pdf txt image in sdcard & uri & assets & url download here https://github.com/Victor2018/DocViewer
- Can't build and run after AGP upgrade
- draw text in a "box"
- PdfBox broke my tests HOT 1
- PDF preview image generate is not working well with pre-filled generated PDF files
- I have my pdf file in assets, Error in rendering [pageImage = renderer.renderImage(0, 1, ImageType.RGB);] HOT 1
- Create PDF from a file(Images) doesn't support HEIC, HEIF, AVIF format
- Blur all objects or Blur page
- pdf convert *.docx Format error (font, color, line break)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfbox-android.