Convert a View to pdf in Sketchware

To convert a LinearLayout along with its contents, into a pdf document, follow the steps given below.
1. Create a new project in Sketchware.

2. In View area add a LinearV linear1. Inside linear1, add contents for the pdf document page. For linear1, set background colour to WHITE or something else.

3. Create a String variable path.

4. Create a more block extra. In more block extra use following codes and blocks:

// Create OptionsMenu.

private static final int PDF = 1;
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, PDF, 0, "toPdf").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
return true;

// Add code for menu item selection.
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case PDF:
// Create pdf document and add linear1 as a page to it.
try { document = new; pageInfo = new, linear1.getHeight(), 1).create(); page = document.startPage(pageInfo);

Canvas canvas = page.getCanvas();
Paint paint = new Paint();

// Set String path to the path for saving pdf document. And write empty string to the path.
// Save pdf document to the path. myfile = new; fout = new; myOutWriter = new;

showMessage("File Saved");
} catch ( Exception e){
return true;
return true; }

5. Run the project.


  1. Sir it works but please tell me how to save it in downloads as I am unable to access it from file manager

  2. How do I get sketchware to show location on a pdf (geopdf)? I'm using webview. Like the app Azenza Maps.

  3. Hello Sanjeev,
    It's not working. Still, i am gonna try. Can i insert, in the linearview, as mutch as i want or how give it a A4page format? And what about, if i have several pages? Please, can you help me?
    Belgium greetings, Tony


Post a Comment

Popular posts from this blog

Create Music Player app in Sketchware

A Flash Light App in Sketchware

Admob rewarded video Ads in Sketchware

Simple car racing android game in Sketchware

Firebase auth in Sketchware for Login Activity