pramodkr123/ConvertWebViewToPdfDemo

Is there a possibility to set Printmargins to 0?

Opened this issue · 2 comments

Hello,
I'd like to print a webview to pdf with a colored banner touching the edges.
Looks good in Webview, but once printed to pdf it gets margins all around.

Is there any way to set these printmargins to 0 ?

Thanks in advance,
Any help would be greatly appreciated.

PrintAttributes attributes = new PrintAttributes.Builder()
.setMediaSize(PrintAttributes.MediaSize.ISO_A4)
.setResolution(new PrintAttributes.Resolution("pdf", "pdf", 600, 600))
.setMinMargins(PrintAttributes.Margins.NO_MARGINS).build();

//change the height and width according to your requirement.
.setResolution(new PrintAttributes.Resolution("pdf", "pdf", 600, 600))

//set margins
.setMinMargins(PrintAttributes.Margins.NO_MARGINS)

Hope It will help you.

Let me know if you are getting any issue.

Thanks for the response, but I have trouble figuring out were I'm supposed to put these PrintAttributes.

I have this:
PdfView.createWebPrintJob(printWebView_Activity.this, webView, directory, fileName, new PdfView.Callback() { ..... }
I havent been able to find a parameter I could fill with the attributes. (Or am I missing something?)