Permalink
Browse files

PDF file signature check

  • Loading branch information...
vfr committed Oct 12, 2012
1 parent 962f8d3 commit 3548ea14e488fe92ce43f1c579962ae6a5b39445
Showing with 5 additions and 10 deletions.
  1. +2 −2 Reader.xcodeproj/project.pbxproj
  2. +3 −8 Sources/ReaderDocument.m
@@ -212,11 +212,11 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
- 8D1107310486CEB800E47090 /* Reader-Info.plist */,
- 4541A9D7122EA716001A5E60 /* Localizable.strings */,
45AB72DF141FC04B003524C3 /* README.md */,
45D5AD9E1610E66B00706B9A /* HISTORY.md */,
45AB72DD141FC043003524C3 /* LICENSE.md */,
+ 8D1107310486CEB800E47090 /* Reader-Info.plist */,
+ 4541A9D7122EA716001A5E60 /* Localizable.strings */,
45AB72DB141FC039003524C3 /* Reader.pdf */,
);
name = Resources;
View
@@ -1,6 +1,6 @@
//
// ReaderDocument.m
-// Reader v2.6.0
+// Reader v2.6.1
//
// Created by Julius Oklamcak on 2011-07-01.
// Copyright © 2011-2012 Julius Oklamcak. All rights reserved.
@@ -179,16 +179,11 @@ + (BOOL)isPDF:(NSString *)filePath
if (fd > 0) // We have a valid file descriptor
{
- const unsigned char sig[4]; // File signature
+ const char sig[1024]; // File signature buffer
ssize_t len = read(fd, (void *)&sig, sizeof(sig));
- if (len == 4)
- if (sig[0] == '%')
- if (sig[1] == 'P')
- if (sig[2] == 'D')
- if (sig[3] == 'F')
- state = YES;
+ state = (strnstr(sig, "%PDF", len) != NULL);
close(fd); // Close the file
}

6 comments on commit 3548ea1

@Rajios

This comment has been minimized.

Show comment Hide comment
@Rajios

Rajios Nov 5, 2012

Hi,
I m new to ios
I need the latest version without ARC or can u suggest the version number

Hi,
I m new to ios
I need the latest version without ARC or can u suggest the version number

@Beulenyoshi

This comment has been minimized.

Show comment Hide comment
@Beulenyoshi

Beulenyoshi Jan 11, 2013

A search function would be really usefull. I've been working on one but got stuck in your Scanner... :/

A search function would be really usefull. I've been working on one but got stuck in your Scanner... :/

@engkhaled

This comment has been minimized.

Show comment Hide comment
@engkhaled

engkhaled Jan 24, 2013

Hi
i would like to use this source code in my project
but i have one problem i wanna make pdf view Display pdf from right to left
not Left to right can you help me plz?
thanks in advance

Hi
i would like to use this source code in my project
but i have one problem i wanna make pdf view Display pdf from right to left
not Left to right can you help me plz?
thanks in advance

@mlibary

This comment has been minimized.

Show comment Hide comment
@mlibary

mlibary Feb 3, 2013

Hi;

Thank you for this useful open source code, but I have one question only :)

I want the book to start navigating from Right to Left (Like an Arabic book).
How can I do that ?!

Thanks in advance :)

Hi;

Thank you for this useful open source code, but I have one question only :)

I want the book to start navigating from Right to Left (Like an Arabic book).
How can I do that ?!

Thanks in advance :)

@kiroskirin

This comment has been minimized.

Show comment Hide comment
@kiroskirin

kiroskirin Mar 18, 2013

Hi, how can I add page flip effect of UIPageViewController to this good open source.

Thanks you.

Hi, how can I add page flip effect of UIPageViewController to this good open source.

Thanks you.

@obaidjawad

This comment has been minimized.

Show comment Hide comment
@obaidjawad

obaidjawad Aug 31, 2013

@mlibary have you attained the functionality from right to left for an arabic book if yes please share it with me as I'm also stuck to it.

@mlibary have you attained the functionality from right to left for an arabic book if yes please share it with me as I'm also stuck to it.

Please sign in to comment.