android-pdfview
android-pdfview copied to clipboard
page shows rotated if rotate is other than 0
if in metadata rotate is other than 0 then page show rotated
I have a pdf that it shows 90 degree rotated. When I open the file in metadatas for each page there is Rotate 90
<</Type/Page/MediaBox [0 0 612 792]
/Rotate 90/Parent 3 0 R
/Resources<</ProcSet[/PDF /ImageC]
/ExtGState 40 0 R
/XObject 41 0 R
>>
@omidaminiva, thank you for your observation. I don't know, when author will fix this moment. But now I can use InputStream and check rotation(may be not better decision, but it works).
public static byte[] BYTES = new byte[1024];
public static boolean isRotate(InputStream inputStream) {
StringBuilder x = new StringBuilder();
int numRead = 0;
try {
while ((numRead = inputStream.read(BYTES)) >= 0) {
x.append(new String(BYTES, 0, numRead));
if (String.valueOf(x).contains("Rotate")) {
if (String.valueOf(x).contains("Rotate 90")) {
return true;
} else {
return false;
}
}
x.delete(0, numRead-20);
}
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
then in init method:
try {
if (Utils.isRotate(new FileInputStream(pdf.path))) {
pdfView.setRotation(90);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Thanks I will give it a try
My decision is bad practice, for list of big pdf files (>20mb and if source has'nt word "Rotation") it has big strain. Also it turns out pdf has not only "Rotate 90". I noticed there is rotated pdf-files, where page source look like this:
2008 0 obj
<</Filter/FlateDecode/First 15/Length 150/N 2/Type/ObjStm>>stream
hÞ2403P0P0440S05S°±ÑwÎ/Í+Q04ÖwË,*2,Í
‚ô}A<s0/¤² Uß¿´$'3/µØΨÏdD)Ä]#˜æf(F@Tù¥V”€ô˜€y‰E© {!îò‹RË@²ë2KrR5þýgžÈ¼€y>ólæ¥ÌK˜g2Ïbž¨ig`
endstream
endobj
where there rotation information? =(
barteksc/AndroidPdfViewer shows correct rotation.