Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
pdf-customizer
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
dfb40125
authored
2016-09-07 09:53:58 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
preview after every input
1 parent
2917db69
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
48 deletions
app/Http/Controllers/ApiController.php
app/Http/routes.php
public/files/js/interfaceGdrive.js
app/Http/Controllers/ApiController.php
View file @
dfb4012
...
...
@@ -33,8 +33,7 @@ class ApiController extends Controller
// $json = '{"pdf":[{"name":"Sample PDF Document","folder":"Sample","pdfLocation":"http://hotelpodlipou.sk/uploads/files/sample.pdf"}],"changes":[{"label":"none","locationUp":"400","locationRight":90,"pages":"1","content":"logo-sample-text_355-558.jpg","z-index":null,"idstylesPDF":1,"order":"2","style":null,"idchange_typePDF":2,"change_type":"2","fileLocation":"https://image.freepik.com/free-vector/logo-sample-text_355-558.jpg"},{"label":"text style","locationUp":"60","locationRight":290,"pages":"1","content":"519.642.4404 London","z-index":null,"idstylesPDF":2,"order":"1","style":"a:3:{s:11:\"font-family\";s:11:\"TradeGothic\";s:9:\"font-size\";s:2:\"14\";s:10:\"font-color\";s:16:\"cmyk 0 0.6 0.5 0\";}","idchange_typePDF":1,"change_type":"1"}]}';
//$styles = serialize(array("font-family"=>"Barber","font-size"=>"20","font-color"=>"cmyk 0 0 0 0","alignment"=>"left"));
//$styles = serialize(array("font-family"=>"Barber","font-size"=>"20","font-color"=>"cmyk 0 0 0 0","alignment"=>"left"));
//print_r($styles);
//die();
$apiCallId
=
new
pdfModel
();
...
...
@@ -43,10 +42,6 @@ class ApiController extends Controller
$pdfId
=
new
pdfModel
();
$pdfId
=
$pdfId
->
addPdf
(
$apiCallId
,
$json
);
$json
=
json_decode
(
$json
);
$storagePath
=
Storage
::
disk
(
'public'
)
->
getDriver
()
->
getAdapter
()
->
getPathPrefix
();
$folder
=
str_replace
(
' '
,
'-'
,
$json
->
pdf
[
0
]
->
name
);
// Replaces all spaces with hyphens.
$folder
=
preg_replace
(
'/[^A-Za-z0-9\-]/'
,
''
,
$folder
);
...
...
@@ -66,10 +61,6 @@ class ApiController extends Controller
$curl
->
download
(
$pdfLocation
,
$storagePath
.
$folder
.
'/'
.
$file
);
$curl
->
close
();
$fileEntry
=
New
FileEntryController
();
// echo $storagePath . $folder . '/' . $file;
//$fileEntry->addfile( $folder . '/' . $file);
$im
=
new
Imagick
();
$im
->
setResolution
(
300
,
300
);
//set the resolution of the resulting jpg
if
(
!
is_readable
(
$storagePath
.
$folder
.
'/'
.
$file
))
{
...
...
@@ -92,32 +83,55 @@ class ApiController extends Controller
$curl
->
close
();
}
}
}
public
function
preview
()
{
$json
=
Input
::
all
();
$json
=
json_encode
(
$json
);
$json
=
json_decode
(
$json
);
$pdfLocation
=
$json
->
pdf
[
0
]
->
pdfLocation
;
$cust_id
=
$json
->
pdf
[
0
]
->
custId
;
$storagePath
=
Storage
::
disk
(
'public'
)
->
getDriver
()
->
getAdapter
()
->
getPathPrefix
();
foreach
(
$json
->
changes
as
$change
)
{
if
(
$change
->
change_type
==
'img'
)
{
$folder
=
str_replace
(
' '
,
'-'
,
$json
->
pdf
[
0
]
->
folder
);
// Replaces all spaces with hyphens.
$folder
=
preg_replace
(
'/[^A-Za-z0-9\-]/'
,
''
,
$folder
);
$fileLocation
=
$change
->
fileLocation
;
$file
=
explode
(
'\\'
,
$change
->
content
);
$file
=
end
(
$file
);
$fileClean
=
str_replace
(
' '
,
'-'
,
$file
);
$curl
=
new
Curl
();
$curl
->
download
(
$fileLocation
.
'/'
.
$fileClean
,
$storagePath
.
$folder
.
'/'
.
$fileClean
);
$curl
->
close
();
}
}
$json
=
json_encode
(
$json
);
$apiCallId
=
"3"
;
$pdfId
=
new
pdfModel
();
$pdfId
=
$pdfId
->
changePdf
(
$apiCallId
,
$json
);
$pdf
=
new
PdfController
();
$pdf
=
$pdf
->
pdf
(
$pdfId
);
$response
=
$pdfId
;
$statusCode
=
200
;
return
Response
::
json
(
$response
,
$statusCode
);
}
public
function
update
()
{
$json
=
Input
::
all
();
$json
=
json_encode
(
$json
);
$json
=
json_decode
(
$json
);
$pdfLocation
=
$json
->
pdf
[
0
]
->
pdfLocation
;
$cust_id
=
$json
->
pdf
[
0
]
->
custId
;
$storagePath
=
Storage
::
disk
(
'public'
)
->
getDriver
()
->
getAdapter
()
->
getPathPrefix
();
foreach
(
$json
->
changes
as
$change
)
{
if
(
$change
->
change_type
==
'img'
)
{
$folder
=
str_replace
(
' '
,
'-'
,
$json
->
pdf
[
0
]
->
folder
);
// Replaces all spaces with hyphens.
$folder
=
preg_replace
(
'/[^A-Za-z0-9\-]/'
,
''
,
$folder
);
$fileLocation
=
$change
->
fileLocation
;
...
...
@@ -127,35 +141,25 @@ class ApiController extends Controller
$curl
=
new
Curl
();
$curl
->
download
(
$fileLocation
.
'/'
.
$fileClean
,
$storagePath
.
$folder
.
'/'
.
$fileClean
);
$curl
->
close
();
// chmod( $storagePath . $folder . '/' . $fileClean, 0777);
}
}
$json
=
json_encode
(
$json
);
// $json = '{"pdf":[{"name":"Sample PDF Document","folder":"Sample","pdfLocation":"http://hotelpodlipou.sk/uploads/files/sample.pdf"}],"changes":[{"label":"none","locationUp":"400","locationRight":90,"pages":"1","content":"logo-sample-text_355-558.jpg","z-index":null,"idstylesPDF":1,"order":"2","style":null,"idchange_typePDF":2,"change_type":"2","fileLocation":"https://image.freepik.com/free-vector/logo-sample-text_355-558.jpg"},{"label":"text style","locationUp":"60","locationRight":290,"pages":"1","content":"519.642.4404 London","z-index":null,"idstylesPDF":2,"order":"1","style":"a:3:{s:11:\"font-family\";s:11:\"TradeGothic\";s:9:\"font-size\";s:2:\"14\";s:10:\"font-color\";s:16:\"cmyk 0 0.6 0.5 0\";}","idchange_typePDF":1,"change_type":"1"}]}';
//$apiCallId = new pdfModel();
// $apiCallId = $apiCallId->addApiCall('1',$json);
$apiCallId
=
"3"
;
$pdfId
=
new
pdfModel
();
$pdfId
=
$pdfId
->
changePdf
(
$apiCallId
,
$json
);
$pdf
=
new
PdfController
();
$pdf
=
$pdf
->
pdf
(
$pdfId
);
$response
=
$pdfId
;
$statusCode
=
200
;
//$UploaqdPdf = new GoogledriveuploadpdfController();
//$UploaqdPdf->google_drive_upload($folder, 'new_'.$pdfLocation,$pdfId,$cust_id);
return
Response
::
json
(
$response
,
$statusCode
);
return
Response
::
json
(
$response
,
$statusCode
);
$UploaqdPdf
=
new
GoogledriveuploadpdfController
();
$UploaqdPdf
->
google_drive_upload
(
$folder
,
'new_'
.
$pdfLocation
,
$pdfId
,
$cust_id
);
}
public
function
getList
(
$json
)
{
$rows
=
new
pdfModel
();
...
...
@@ -170,8 +174,6 @@ class ApiController extends Controller
public
function
getPdf
(
$json
)
{
$rows
=
new
pdfModel
();
$rows
=
$rows
->
getpdf
(
$json
)
->
get
();
$response
=
$rows
;
...
...
@@ -181,8 +183,6 @@ class ApiController extends Controller
}
public
function
getPdfPriev
(
$json
)
{
$rows
=
new
pdfModel
();
$rows
=
$rows
->
getpdf
(
$json
)
->
get
();
$response
=
$rows
;
...
...
@@ -195,8 +195,6 @@ class ApiController extends Controller
$rows
=
new
pdfModel
();
$id
=
$rows
->
getpdfid
(
$json
)
->
get
();
$rows
=
$rows
->
getpdf
(
$id
[
0
]
->
pdfid
)
->
get
();
$response
=
$rows
;
$statusCode
=
200
;
...
...
app/Http/routes.php
View file @
dfb4012
...
...
@@ -23,34 +23,29 @@ Route::get('pdf/{id}', 'PdfController@pdf');
Route
::
group
(
array
(
'prefix'
=>
'api/v1'
),
function
(
$json
)
{
Route
::
resource
(
'add'
,
'ApiController@insert'
);
Route
::
resource
(
'get-list'
,
'ApiController@getList'
);
Route
::
resource
(
'get-pdf'
,
'ApiController@getpdf'
);
Route
::
resource
(
'api'
,
'FileEntryController@getApi'
);
Route
::
resource
(
'get-pdf-google'
,
'ApiController@getpdfgoogle'
);
});
Route
::
any
(
'api/update'
,
'ApiController@update'
);
Route
::
any
(
'api/preview'
,
'ApiController@preview'
);
Route
::
post
(
'api/authenticate'
,
'AuthenticateController@authenticate'
);
Route
::
get
(
'api/authenticate/user'
,
'AuthenticateController@getAuthenticatedUser'
);
Route
::
any
(
'fileentry/postUpload'
,
'FileEntryController@postUpload'
);
Route
::
get
(
'fileentry/get/{filename}'
,
[
'as'
=>
'getentry'
,
'uses'
=>
'FileEntryController@get'
]);
Route
::
any
(
'fileentry/postUpload'
,
'FileEntryController@postUpload'
);
Route
::
get
(
'fileentry/get/{filename}'
,
[
'as'
=>
'getentry'
,
'uses'
=>
'FileEntryController@get'
]);
Route
::
get
(
'fileentry'
,
'FileEntryController@index'
);
Route
::
get
(
'fileentry/getImage/{folder}/{filename}'
,
'FileEntryController@getImage'
);
Route
::
get
(
'fileentry/getPDF/{folder}/{filename}'
,
'FileEntryController@getPDF'
);
Route
::
post
(
'fileentry/add'
,[
'as'
=>
'addentry'
,
'uses'
=>
'FileEntryController@add'
]);
Route
::
post
(
'fileentry/add'
,[
'as'
=>
'addentry'
,
'uses'
=>
'FileEntryController@add'
]);
Route
::
get
(
'api/googlePdfUpload/{folder}/{filename}/{pdfid}/{id}'
,
'GoogledriveuploadpdfController@google_drive_upload'
);
Route
::
get
(
'auth/google/callback'
,
'GoogledriveuploadpdfController@google_drive_upload'
);
...
...
public/files/js/interfaceGdrive.js
View file @
dfb4012
This diff is collapsed.
Click to expand it.
Please
register
or
sign in
to post a comment