aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcms <cms@beatworm.co.uk>2016-10-12 10:01:13 (GMT)
committercms <cms@beatworm.co.uk>2016-10-12 10:01:13 (GMT)
commitd3b7ad2fb2334f27f6cf5adb2fa47929cd511be0 (patch)
tree258838f06f508cb9d4f84c65c62ee594ce24bcfb
parentaea41cf7d8c63eee873ad6f655b64f725cab1639 (diff)
downloadhydra-d3b7ad2fb2334f27f6cf5adb2fa47929cd511be0.zip
hydra-d3b7ad2fb2334f27f6cf5adb2fa47929cd511be0.tar.gz
hydra-d3b7ad2fb2334f27f6cf5adb2fa47929cd511be0.tar.bz2
put the file loading into the application init
see if it speeds things up. (it doesn't really) either way, web handler instances probably should be loading the master pdf
-rw-r--r--src/HydraApplication.cpp12
-rw-r--r--src/HydraApplication.h7
-rw-r--r--src/HydraRootHandler.cpp14
3 files changed, 22 insertions, 11 deletions
diff --git a/src/HydraApplication.cpp b/src/HydraApplication.cpp
index 8c84b7a..99cdc01 100644
--- a/src/HydraApplication.cpp
+++ b/src/HydraApplication.cpp
@@ -1,12 +1,23 @@
#include "HydraApplication.h"
#include "HydraRequestHandlerFactory.h"
+#include <iostream>
namespace Hydra {
+ FPDF_DOCUMENT the_doc ;
+
void Application::initialize(Poco::Util::Application& self)
{
sock = Poco::Net::ServerSocket(2225);
pParams = new Poco::Net::HTTPServerParams;
+ the_doc = FPDF_LoadDocument("test.pdf", NULL);
+
+ if (!the_doc) {
+ std::cerr << "an error occurred reading" << std::endl;
+ } else {
+ std::cerr << "loaded the PDF file" << std::endl;
+ }
+
}
int Application::main(const std::vector<std::string>& args)
@@ -17,5 +28,4 @@ namespace Hydra {
return 0;
}
-
}
diff --git a/src/HydraApplication.h b/src/HydraApplication.h
index cce6d5e..a41d484 100644
--- a/src/HydraApplication.h
+++ b/src/HydraApplication.h
@@ -3,6 +3,7 @@
#include "Poco/Net/ServerSocket.h"
#include "Poco/Net/HTTPServerParams.h"
#include "Poco/Net/HTTPServer.h"
+#include "fpdfview.h"
namespace Hydra
{
@@ -11,8 +12,14 @@ namespace Hydra
public:
void initialize(Poco::Util::Application& self);
int main(const std::vector<std::string>& args);
+ FPDF_DOCUMENT doc();
private:
Poco::Net::ServerSocket sock;
Poco::Net::HTTPServerParams* pParams;
+
+ //FPDF_STRING the_pdf = "test.pdf";
+
+
+
};
};
diff --git a/src/HydraRootHandler.cpp b/src/HydraRootHandler.cpp
index 6003e56..48ba447 100644
--- a/src/HydraRootHandler.cpp
+++ b/src/HydraRootHandler.cpp
@@ -1,6 +1,7 @@
#include "HydraRootHandler.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/HTTPServerResponse.h"
+#include "HydraApplication.h"
#include "fpdfview.h"
#include <iostream>
@@ -59,26 +60,19 @@ namespace Hydra {
FPDF_InitLibraryWithConfig(&config);
- FPDF_STRING the_pdf = "test.pdf";
- FPDF_DOCUMENT doc = FPDF_LoadDocument(the_pdf, NULL);
-
- if (!doc) {
- std::cerr << "an error occurred reading" << std::endl;
- }
+ extern FPDF_DOCUMENT the_doc;
- FPDF_PAGE page = FPDF_LoadPage(doc,0);
+ FPDF_PAGE page = FPDF_LoadPage(the_doc,0);
if (!page) {
std::cerr << "An error occurred loading page 0" << std::endl;
}
+ std::cerr << "Height is " << FPDF_GetPageHeight(page);
std::cerr << "OK GOT A PAGE" << std::endl;
FPDF_BITMAP bmp = FPDFBitmap_Create(600,600,1);
FPDFBitmap_FillRect(bmp, 0, 0, 600, 600, 0xccccccff);
FPDF_RenderPageBitmap(bmp,page,0,0,600,600,0,0);
- FPDF_CloseDocument(doc);
-
-
response.setContentType("image/x-portable-pixmap");
response.setChunkedTransferEncoding(true);