Follow Our Blog For Not Missing Any ContentContact Us Follow!

Convert Webpage To Pdf In Sketchware

Convert Webpage To Pdf In Sketchware
Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

 Convert Webpage To Pdf In Sketchware 


Follow the instructions below to convert a web page displayed in a WebView to a PDF in Sketchware.


1. Add the following codes to a More block you create in your Sketchware project.

}

android.print.PrintJob printJob;


@androidx.annotation.RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)

private void PrintTheWebPage(WebView webView) {

android.print.PrintManager printManager = (android.print.PrintManager) this.getSystemService(Context.PRINT_SERVICE);

String jobName = "My_webpage" + webView.getUrl();

android.print.PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter(jobName);

assert printManager != null;

printJob = printManager.print(jobName, printAdapter, new android.print.PrintAttributes.Builder().build());

}

{

 2. In the button click event for saving the webpage as pdf put following codes.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

PrintTheWebPage(webview1);

} else { 

showMessage("Not available for device below Android LOLLIPOP");

}

*Here change webview1 to id of your WebView. 

3. Done. Save and run the project


Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.