2025-11-27 11:32:50 +05:00
|
|
|
diff --git a/node_modules/react-native-html-to-pdf-lite/android/build.gradle b/node_modules/react-native-html-to-pdf-lite/android/build.gradle
|
|
|
|
|
index 4f30b21..a45cb85 100644
|
|
|
|
|
--- a/node_modules/react-native-html-to-pdf-lite/android/build.gradle
|
|
|
|
|
+++ b/node_modules/react-native-html-to-pdf-lite/android/build.gradle
|
|
|
|
|
@@ -1,18 +1,3 @@
|
|
|
|
|
-
|
|
|
|
|
-buildscript {
|
|
|
|
|
- repositories {
|
|
|
|
|
- google()
|
|
|
|
|
- jcenter()
|
|
|
|
|
- maven { url "https://jitpack.io" }
|
|
|
|
|
- }
|
|
|
|
|
- dependencies {
|
|
|
|
|
- classpath 'com.android.tools.build:gradle:3.3.1'
|
|
|
|
|
-
|
|
|
|
|
- // NOTE: Do not place your application dependencies here; they belong
|
|
|
|
|
- // in the individual module build.gradle files
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
def safeExtGet(prop, fallback) {
|
|
|
|
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
|
|
|
}
|
2023-07-27 16:25:50 +05:00
|
|
|
diff --git a/node_modules/react-native-html-to-pdf-lite/android/src/main/java/android/print/PdfConverter.java b/node_modules/react-native-html-to-pdf-lite/android/src/main/java/android/print/PdfConverter.java
|
2023-08-04 12:09:57 +05:00
|
|
|
index e2b536b..a85f24a 100644
|
2023-07-27 16:25:50 +05:00
|
|
|
--- a/node_modules/react-native-html-to-pdf-lite/android/src/main/java/android/print/PdfConverter.java
|
|
|
|
|
+++ b/node_modules/react-native-html-to-pdf-lite/android/src/main/java/android/print/PdfConverter.java
|
|
|
|
|
@@ -8,6 +8,7 @@ package android.print;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.os.Build;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
+import android.os.Looper;
|
|
|
|
|
import android.os.ParcelFileDescriptor;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.webkit.WebView;
|
2023-08-04 12:09:57 +05:00
|
|
|
@@ -59,42 +60,51 @@ public class PdfConverter implements Runnable {
|
2023-07-27 16:25:50 +05:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
2023-08-04 12:09:57 +05:00
|
|
|
+
|
2023-07-27 16:25:50 +05:00
|
|
|
mWebView = new WebView(mContext);
|
|
|
|
|
+ mWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
|
|
|
|
+ mWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
|
|
+ mWebView.getSettings().setAllowContentAccess(true);
|
|
|
|
|
+ mWebView.getSettings().setAllowFileAccess(true);
|
|
|
|
|
mWebView.setWebViewClient(new WebViewClient() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onPageFinished(WebView view, String url) {
|
|
|
|
|
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
|
|
|
|
|
- throw new RuntimeException("call requires API level 19");
|
|
|
|
|
- else {
|
|
|
|
|
- PrintDocumentAdapter documentAdapter = mWebView.createPrintDocumentAdapter();
|
|
|
|
|
- documentAdapter.onLayout(null, getPdfPrintAttrs(), null, new PrintDocumentAdapter.LayoutResultCallback() {
|
|
|
|
|
- }, null);
|
|
|
|
|
- documentAdapter.onWrite(new PageRange[]{PageRange.ALL_PAGES}, getOutputFileDescriptor(), null, new PrintDocumentAdapter.WriteResultCallback() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onWriteFinished(PageRange[] pages) {
|
|
|
|
|
- try {
|
|
|
|
|
- String base64 = "";
|
|
|
|
|
- if (mShouldEncode) {
|
|
|
|
|
- base64 = encodeFromFile(mPdfFile);
|
|
|
|
|
+ final Handler handler = new Handler(Looper.getMainLooper());
|
|
|
|
|
+ handler.postDelayed(() -> {
|
|
|
|
|
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
|
|
|
|
|
+ throw new RuntimeException("call requires API level 19");
|
|
|
|
|
+ else {
|
|
|
|
|
+ PrintDocumentAdapter documentAdapter = mWebView.createPrintDocumentAdapter();
|
|
|
|
|
+ documentAdapter.onLayout(null, getPdfPrintAttrs(), null, new PrintDocumentAdapter.LayoutResultCallback() {
|
|
|
|
|
+ }, null);
|
|
|
|
|
+ documentAdapter.onWrite(new PageRange[]{PageRange.ALL_PAGES}, getOutputFileDescriptor(), null, new PrintDocumentAdapter.WriteResultCallback() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onWriteFinished(PageRange[] pages) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ String base64 = "";
|
|
|
|
|
+ if (mShouldEncode) {
|
|
|
|
|
+ base64 = encodeFromFile(mPdfFile);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ PDDocument myDocument = PDDocument.load(mPdfFile);
|
|
|
|
|
+ int pagesToBePrinted = myDocument.getNumberOfPages();
|
|
|
|
|
+
|
|
|
|
|
+ mResultMap.putString("filePath", mPdfFile.getAbsolutePath());
|
|
|
|
|
+ mResultMap.putString("numberOfPages", String.valueOf(pagesToBePrinted));
|
|
|
|
|
+ mResultMap.putString("base64", base64);
|
|
|
|
|
+ mPromise.resolve(mResultMap);
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ mPromise.reject(e.getMessage());
|
|
|
|
|
+ } finally {
|
2023-08-04 12:09:57 +05:00
|
|
|
+ destroy();
|
2023-07-27 16:25:50 +05:00
|
|
|
}
|
|
|
|
|
-
|
|
|
|
|
- PDDocument myDocument = PDDocument.load(mPdfFile);
|
|
|
|
|
- int pagesToBePrinted = myDocument.getNumberOfPages();
|
|
|
|
|
-
|
|
|
|
|
- mResultMap.putString("filePath", mPdfFile.getAbsolutePath());
|
|
|
|
|
- mResultMap.putString("numberOfPages", String.valueOf(pagesToBePrinted));
|
|
|
|
|
- mResultMap.putString("base64", base64);
|
|
|
|
|
- mPromise.resolve(mResultMap);
|
|
|
|
|
- } catch (IOException e) {
|
|
|
|
|
- mPromise.reject(e.getMessage());
|
|
|
|
|
- } finally {
|
|
|
|
|
- destroy();
|
|
|
|
|
}
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
2023-08-04 12:09:57 +05:00
|
|
|
+ }, 1000 * 3);
|
2023-07-27 16:25:50 +05:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
+
|
|
|
|
|
WebSettings settings = mWebView.getSettings();
|
|
|
|
|
settings.setDefaultTextEncodingName("utf-8");
|
|
|
|
|
mWebView.loadDataWithBaseURL(mBaseURL, mHtmlString, "text/HTML", "utf-8", null);
|
|
|
|
|
diff --git a/node_modules/react-native-html-to-pdf-lite/ios/RNHTMLtoPDF/RNHTMLtoPDF.m b/node_modules/react-native-html-to-pdf-lite/ios/RNHTMLtoPDF/RNHTMLtoPDF.m
|
2023-08-04 12:09:57 +05:00
|
|
|
index e005f2a..17a60c5 100644
|
2023-07-27 16:25:50 +05:00
|
|
|
--- a/node_modules/react-native-html-to-pdf-lite/ios/RNHTMLtoPDF/RNHTMLtoPDF.m
|
|
|
|
|
+++ b/node_modules/react-native-html-to-pdf-lite/ios/RNHTMLtoPDF/RNHTMLtoPDF.m
|
|
|
|
|
@@ -74,7 +74,10 @@ + (BOOL)requiresMainQueueSetup
|
|
|
|
|
- (instancetype)init
|
|
|
|
|
{
|
|
|
|
|
if (self = [super init]) {
|
|
|
|
|
- _webView = [[WKWebView alloc] initWithFrame:self.bounds];
|
|
|
|
|
+
|
|
|
|
|
+ WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
|
|
|
|
|
+ wkWebViewConfig.websiteDataStore = [WKWebsiteDataStore defaultDataStore];
|
|
|
|
|
+ _webView = [[WKWebView alloc] initWithFrame:self.bounds configuration:wkWebViewConfig];
|
|
|
|
|
_webView.navigationDelegate = self;
|
|
|
|
|
[self addSubview:_webView];
|
|
|
|
|
autoHeight = false;
|
|
|
|
|
@@ -186,36 +189,38 @@ -(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigati
|
|
|
|
|
if (webView.isLoading)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
- UIPrintPageRenderer *render = [[UIPrintPageRenderer alloc] init];
|
|
|
|
|
- [render addPrintFormatter:webView.viewPrintFormatter startingAtPageAtIndex:0];
|
2023-08-04 12:09:57 +05:00
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
2023-07-27 16:25:50 +05:00
|
|
|
+ UIPrintPageRenderer *render = [[UIPrintPageRenderer alloc] init];
|
|
|
|
|
+ [render addPrintFormatter:webView.viewPrintFormatter startingAtPageAtIndex:0];
|
2023-08-04 12:09:57 +05:00
|
|
|
|
2023-07-27 16:25:50 +05:00
|
|
|
- // Define the printableRect and paperRect
|
|
|
|
|
- // If the printableRect defines the printable area of the page
|
|
|
|
|
- CGRect paperRect = CGRectMake(0, 0, _PDFSize.width, _PDFSize.height);
|
|
|
|
|
- CGRect printableRect = CGRectMake(_paddingLeft, _paddingTop, _PDFSize.width-(_paddingLeft + _paddingRight), _PDFSize.height-(_paddingBottom + _paddingTop));
|
|
|
|
|
+ // Define the printableRect and paperRect
|
|
|
|
|
+ // If the printableRect defines the printable area of the page
|
|
|
|
|
+ CGRect paperRect = CGRectMake(0, 0, _PDFSize.width, _PDFSize.height);
|
|
|
|
|
+ CGRect printableRect = CGRectMake(_paddingLeft, _paddingTop, _PDFSize.width-(_paddingLeft + _paddingRight), _PDFSize.height-(_paddingBottom + _paddingTop));
|
2023-08-04 12:09:57 +05:00
|
|
|
|
|
|
|
|
|
2023-07-27 16:25:50 +05:00
|
|
|
- [render setValue:[NSValue valueWithCGRect:paperRect] forKey:@"paperRect"];
|
|
|
|
|
- [render setValue:[NSValue valueWithCGRect:printableRect] forKey:@"printableRect"];
|
|
|
|
|
+ [render setValue:[NSValue valueWithCGRect:paperRect] forKey:@"paperRect"];
|
|
|
|
|
+ [render setValue:[NSValue valueWithCGRect:printableRect] forKey:@"printableRect"];
|
2023-08-04 12:09:57 +05:00
|
|
|
|
2023-07-27 16:25:50 +05:00
|
|
|
- NSData * pdfData = [render printToPDF:&_numberOfPages backgroundColor:_bgColor ];
|
|
|
|
|
+ NSData * pdfData = [render printToPDF:&_numberOfPages backgroundColor:_bgColor ];
|
2023-08-04 12:09:57 +05:00
|
|
|
|
2023-07-27 16:25:50 +05:00
|
|
|
- if (pdfData) {
|
|
|
|
|
- NSString *pdfBase64 = @"";
|
|
|
|
|
+ if (pdfData) {
|
|
|
|
|
+ NSString *pdfBase64 = @"";
|
2023-08-04 12:09:57 +05:00
|
|
|
|
2023-07-27 16:25:50 +05:00
|
|
|
- [pdfData writeToFile:_filePath atomically:YES];
|
|
|
|
|
- if (_base64) {
|
|
|
|
|
- pdfBase64 = [pdfData base64EncodedStringWithOptions:0];
|
|
|
|
|
+ [pdfData writeToFile:_filePath atomically:YES];
|
|
|
|
|
+ if (_base64) {
|
|
|
|
|
+ pdfBase64 = [pdfData base64EncodedStringWithOptions:0];
|
|
|
|
|
+ }
|
|
|
|
|
+ NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
|
+ pdfBase64, @"base64",
|
|
|
|
|
+ [NSString stringWithFormat: @"%ld", (long)_numberOfPages], @"numberOfPages",
|
|
|
|
|
+ _filePath, @"filePath", nil];
|
|
|
|
|
+ _resolveBlock(data);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ NSError *error;
|
|
|
|
|
+ _rejectBlock(RCTErrorUnspecified, nil, RCTErrorWithMessage(error.description));
|
|
|
|
|
}
|
|
|
|
|
- NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
|
- pdfBase64, @"base64",
|
|
|
|
|
- [NSString stringWithFormat: @"%ld", (long)_numberOfPages], @"numberOfPages",
|
|
|
|
|
- _filePath, @"filePath", nil];
|
|
|
|
|
- _resolveBlock(data);
|
|
|
|
|
- } else {
|
|
|
|
|
- NSError *error;
|
|
|
|
|
- _rejectBlock(RCTErrorUnspecified, nil, RCTErrorWithMessage(error.description));
|
|
|
|
|
- }
|
|
|
|
|
+ });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
2021-06-03 10:13:38 +05:00
|
|
|
diff --git a/node_modules/react-native-html-to-pdf-lite/react-native-html-to-pdf.podspec b/node_modules/react-native-html-to-pdf-lite/react-native-html-to-pdf-lite.podspec
|
|
|
|
|
similarity index 100%
|
|
|
|
|
rename from node_modules/react-native-html-to-pdf-lite/react-native-html-to-pdf.podspec
|
|
|
|
|
rename to node_modules/react-native-html-to-pdf-lite/react-native-html-to-pdf-lite.podspec
|