#Separation studio 4 save as pdf android#
The code below works as expected in Android 4.4 but not in later versions. But what we can do is to create Pages in a ratio of A4 or Letter size, so it can fit into print out paper format.īut there is another issue I'm facing.
#Separation studio 4 save as pdf pdf#
It might be a late answer but I was also in need of similar solution with Print Framework so far, and I splitted the Pdf Document into pages with the code below.Īs far as I can see, you cannot really make the WebView or Pdf Document splits your pdf file into pages in a smart way (not cutting the text or image). Or: Is there a way I can convert my WebView object into a PDF and allow for page breaks. My question is: can I specify that I want the PrintManager to perform a "Save as PDF" and provide the name and location of the resulting file so that there is no interaction with the user? PrintJob printJob = printManager.print(jobName, printAdapter, PrintAttributes printAttrs = new PrintAttributes.Builder(). String jobName = getString(R.string.app_name) + " Report " PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter() PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE) If I use the PrintManager and create a print adapter from the WebView object with createPrintDocumentAdapter, I can select the "Save as PDF" option and the resulting pdf file has the page breaks as I specify in the CSS of the original web page. PrintedPdfDocument document = new PrintedPdfDocument(mContext,pdfPrintAttrs) If I change it so that I use the PrintedPdfDocumet and don't specify the PageInfo I only get the viewable part of the WebView object. Page page = document.startPage(pageInfo) PageInfo pageInfo = new PageInfo.Builder(webView.getMeasuredWidth(), webView.getContentHeight(), 1).create() PdfDocument document = new PrintedPdfDocument(mContext,pdfPrintAttrs) SetResolution(new Resolution("zooey", PRINT_SERVICE, 300, 300)). SetColorMode(PrintAttributes.COLOR_MODE_MONOCHROME). PrintAttributes pdfPrintAttrs = new PrintAttributes.Builder(). I save the file, and this works, except that the result is a single page document. draw onto the page from the WebView object. I have been able to convert it using PdfDocument, and doing.
What I would like to be able to do is convert this WebView into a pdf document. I use the WebView object to display the report in my app. I am working on an application (Android 4.4 - API 20) where I am generating a report in HTML format.