Posts

Showing posts with the label Create pdf document in Sketchware

Convert a View to pdf in Sketchware

Image
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; @Override 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. @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case PDF: // Create pdf document and add linear1 as a page to it. try { android.graphics.pdf.PdfDocument document = new android.graphics.pdf.PdfDocument(); android.graphics.pdf.PdfDocume...