-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPdfWriter.cpp
42 lines (33 loc) · 1.42 KB
/
PdfWriter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "./PdfWriter.h"
pdfwrite::PDFWriter pdf;
JNIEXPORT void JNICALL Java_PdfWriter_setWidthHeight (JNIEnv * evn, jobject thisobj, jint width, jint height){
pdf.setWidthHeight(width, height);
}
JNIEXPORT void JNICALL Java_PdfWriter_setFont (JNIEnv *env, jobject thisobj, jint font, jint size){
pdf.pdfSetFont(static_cast<pdfwrite::Font>(font), size);
}
JNIEXPORT void JNICALL Java_PdfWriter_setContent (JNIEnv *env, jobject thisobj, jstring content){
const char *inCStr = env->GetStringUTFChars(content, 0);
std::string str(inCStr);
pdf.pdfSetContent(str);
env->ReleaseStringUTFChars(content, inCStr);
}
JNIEXPORT void JNICALL Java_PdfWriter_warpText (JNIEnv *env, jobject thisobj, jint maxwidth, jboolean isRightAligned){
pdf.warpText(maxwidth, isRightAligned);
}
JNIEXPORT void JNICALL Java_PdfWriter_addToPage (JNIEnv *env, jobject thisobj){
pdf.pdfAddToPage();
}
JNIEXPORT void JNICALL Java_PdfWriter_addNewPage (JNIEnv *env, jobject thisobj){
pdf.pdfAddNewPage();
}
JNIEXPORT jboolean JNICALL Java_PdfWriter_writeToFile (JNIEnv *env, jobject thisobj, jstring filename){
const char *inCStr = env->GetStringUTFChars(filename, 0);
std::string file(inCStr);
std::string err;
env->ReleaseStringUTFChars(filename, inCStr);
return pdf.writeToFile(file, err);
}
JNIEXPORT void JNICALL Java_PdfWriter_setXY (JNIEnv *env, jobject thisobj, jint x, jint y){
pdf.setXY(x, y);
}