Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .idea/easyPDF.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

787 changes: 787 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file modified db.sqlite3
Binary file not shown.
Binary file added easyPDF/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added easyPDF/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added easyPDF/__pycache__/settings.cpython-36.pyc
Binary file not shown.
Binary file added easyPDF/__pycache__/settings.cpython-37.pyc
Binary file not shown.
Binary file added easyPDF/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added easyPDF/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file added easyPDF/__pycache__/wsgi.cpython-36.pyc
Binary file not shown.
Binary file added easyPDF/__pycache__/wsgi.cpython-37.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions easyPDF/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
from os.path import join

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


Expand Down
Binary file not shown.
Binary file added utils/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added utils/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added utils/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file added utils/__pycache__/admin.cpython-37.pyc
Binary file not shown.
Binary file added utils/__pycache__/apps.cpython-36.pyc
Binary file not shown.
Binary file added utils/__pycache__/apps.cpython-37.pyc
Binary file not shown.
Binary file added utils/__pycache__/functions.cpython-37.pyc
Binary file not shown.
Binary file added utils/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file added utils/__pycache__/models.cpython-37.pyc
Binary file not shown.
Binary file added utils/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added utils/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file added utils/__pycache__/views.cpython-36.pyc
Binary file not shown.
Binary file added utils/__pycache__/views.cpython-37.pyc
Binary file not shown.
17 changes: 17 additions & 0 deletions utils/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import shutil
from PyPDF2 import PdfFileReader,PdfFileWriter
def function_split(ar,path):
inputPdf=open(path,'rb')
pdfReader=PdfFileReader(inputPdf)
#print "No. of pages ",pdfReader.getNumPages()

for i in range(pdfReader.numPages):
output = PdfFileWriter()
output.addPage(pdfReader.getPage(i))
with open(os.path.join("splitted//%s.pdf") % (i+1), "wb") as outputStream:
output.write(outputStream)
inputPdf.close()
os.remove(path)
shutil.make_archive(os.path.join("todownload//download"),'zip',os.path.join('splitted'))
return True
Binary file added utils/migrations/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added utils/migrations/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion utils/static/utils/index.css

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions utils/static/utils/text.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.utilsName
{
font-size: 40px;
color: white;
font-family: "Chaparral Pro";
}
.utilsText{
font-size: 20px;
font-style: italic;
color: #fe944a;
}
hr{
border-color: #fe944a;
}
25 changes: 25 additions & 0 deletions utils/templates/utils/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Footer</title>

<style>
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #222;
color: white;
text-align: center;
}
</style>
</head>
<body>
<div class="footer">
<p>Developed by ReadyBrains | 2018</p>
</div>

</body>
</html>
3 changes: 3 additions & 0 deletions utils/templates/utils/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="{% static 'utils/navbar.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'utils/text.css' %}">
</head>
<div class="example3">
<nav class="navbar navbar-inverse navbar-static-top">
Expand Down Expand Up @@ -39,5 +40,7 @@
{% endblock %}



</div>

</html>
24 changes: 4 additions & 20 deletions utils/templates/utils/home.html
Original file line number Diff line number Diff line change
@@ -1,47 +1,31 @@
{% include 'utils/header.html' %}
{% include 'utils/footer.html' %}
{% load staticfiles %}
{% block title %}
<title>Home</title>
{% endblock %}
{% block body %}
<div class="container">
<div class="row">
<div class="col-md-3" style="background: #222; margin-top: 10px;padding: 10px">
<div class="col-md-3" style="background: #222; margin-top: 10px;padding: 10px;border-radius: 25px;">
<!--<img class="img-responsive center-block" src="{% static "utils/images/merge.png"%}"><hr/>-->
<p class="utilsName">Merge PDFs</p>
<p class="utilsText">Merge multiple PDF files into one quickly and easily</p><hr/>
<button class="btn btn-primary" style="background: #fe944a;border: black;width: 120px" onclick="location.href='{% url 'utils:merge' %}'">Go</button>

</div>
<div class="col-md-3 " style="background: #222; padding: 10px;margin-top: 10px; margin-left: 10px;margin-right: 10px">
<div class="col-md-3 " style="background: #222; padding: 10px;margin-top: 10px; margin-left: 10px;margin-right: 10px;border-radius: 25px;">
<!--<img class="img-responsive center-block" src="{% static "utils/images/split.png"%}"><hr/>-->
<p class="utilsName">Split PDF</p>
<p class="utilsText">Split PDF file into pieces or pick just a few pages</p><hr/>
<button class="btn btn-primary" style="background: #fe944a;border: black;width: 120px" onclick="location.href='{% url 'utils:split' %}'">Go</button>
</div>
<div class="col-md-3" style="background: #222; margin-top: 10px;padding: 10px">
<div class="col-md-3" style="background: #222; margin-top: 10px;padding: 10px;border-radius: 25px;">
<!--<img class="img-responsive center-block" src="{% static "utils/images/rotate.png"%}" ><hr/>-->
<p class="utilsName">Rotate PDF</p>
<p class="utilsText">Rotate a few PDF pages or change orientation of all pages</p><hr/>
<button class="btn btn-primary" style="background: #fe944a;border: black;width: 120px" onclick="location.href='{% url 'utils:rotate' %}'">Go</button>
</div>
</div>
</div>

<style>
.utilsName
{
font-size: 40px;
color: white;
font-family: "Chaparral Pro";
}
.utilsText{
font-size: 20px;
font-style: italic;
color: #fe944a;
}
hr{
border-color: #fe944a;
}
</style>
{% endblock %}
3 changes: 2 additions & 1 deletion utils/templates/utils/merge.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{% include 'utils/header.html' %}
{% include 'utils/footer.html' %}
{% load staticfiles %}
{% block title %}
<title>Merge</title>
{% endblock %}
{% block body %}
Merge
{{ context}}
{% endblock %}
1 change: 1 addition & 0 deletions utils/templates/utils/rotate.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% include 'utils/header.html' %}
{% include 'utils/footer.html' %}
{% load staticfiles %}
{% block title %}
<title>Rotate</title>
Expand Down
27 changes: 26 additions & 1 deletion utils/templates/utils/split.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
{% include 'utils/header.html' %}
{% include 'utils/footer.html' %}
{% load staticfiles %}
{% block title %}
<title>Split</title>
{% endblock %}
{% block body %}
Split
<div class="container">
<div class="row">
<div class="col-md-4" style="background:#222222; padding: 10px;border-radius: 25px;">
<form action="{% url 'utils:split_do' %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="upload" multiple required style="margin-bottom: 20px;color: #fe944a"/>
<input type="radio" name="single" value="1" onchange="document.getElementById('range').disabled=true;document.getElementById('range').value='';"><label class="utilsText">Split into single pages</label><br/>
<input type="radio" name="single" value="2" onchange="document.getElementById('range').disabled=false;"><label class="utilsText">Custom Split</label><br/>
<input type="text" id="range" class="utilsText" name="range" style="background: #222222; border-color:#fe944a;box-shadow: #fe944a;" placeholder="Refer to Help"><br/>
<input type="submit" style="background:#fe944a;border: #fe944a;margin-top: 10px;width: 120px" class="btn btn-primary" >
</form>
</div>


<div class="col-md-6" style="background:#222222;margin-left: 10px;padding:10px;border-radius: 25px;">
<h1 class="utilsName">Help</h1><hr/>
<ol class="utilsText">
<li>To split PDF into single pages select oprion 1.</li>
<li>Otherwise select the second option and input the ranges as :<br/>
if you want to split a pdf of 10 pages into 3 parts then input :<br/> <b>1-3,4-7,8-10</b>
</li>
</ol>
</div>
</div>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions utils/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
url(r'^merge/$',merge,name='merge'),
url(r'^split/$',split,name='split'),
url(r'^rotate/$',rotate,name='rotate'),
url(r'^split/do/$',split_do,name='split_do'),
]
32 changes: 30 additions & 2 deletions utils/views.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.core.files.storage import FileSystemStorage
from django.template import loader
from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
from utils.functions import function_split


def home(request):
temp=loader.get_template('utils/home.html')
context={}
return HttpResponse(temp.render(context,request))

def merge(request):
request.session['id']=3135153
s=request.session['id']
temp=loader.get_template('utils/merge.html')
context={}
context={'s':s}
return HttpResponse(temp.render(context,request))

def split(request):
Expand All @@ -23,4 +30,25 @@ def split(request):
def rotate(request):
temp=loader.get_template('utils/rotate.html')
context={}
return HttpResponse(temp.render(context,request))
return HttpResponse(temp.render(context,request))

def split_do(request):
single=request.POST['single']
rng=''
if(single=='2'):
rng=request.POST['range']
myfile = request.FILES['upload']
fs = FileSystemStorage(location='tosplit/')
n=myfile.name
print(n)
n=n.replace(" ","_")
filename = fs.save(n, myfile)
print(filename)
uploaded_file_url = fs.url(filename)
path=fs.location+(' \ ').strip()+uploaded_file_url
print(path)
if(function_split(rng,path)):
return HttpResponse('<a href="">Download file</a>')
else:

return HttpResponse('something went wrong')
Loading