studio services printer print google example android html webview android-webview google-cloud-print

services - ¿Cómo eliminar la impresión de Android WebView margen añadido?



google cloud print api javascript (4)

Por defecto, las páginas web HTML tienen un relleno y un margen de 10px; Tienes que configurar en tu sección principal o archivo css:

<style type="text/css"> html, body { width:100%; height: 100%; margin: 0px; padding: 0px; }

Es un trabajo para mí. Espero que te ayude :)

o puedes probar otro:

Reemplace su etiqueta con esta:

<body style=''margin:0;padding:0;''>

Aquí hay otro consejo para las imágenes en una vista web: agregue un estilo que se ajuste a las imágenes en el ancho de la pantalla. Funciona muy bien en todos los tamaños de pantalla:

<style type=''text/css''> img {max-width: 100%;height:initial;} div,p,span,a {max-width: 100%;} </style>

Intentamos imprimir un contenido de vista web en Google Cloud Print, pero no importa lo que hagamos, la impresión resultante agrega cierto margen.

¿Hay alguna manera de eliminar este margen? Nosotros tratamos:

<body style="margin: 0; padding: 0">

entonces

<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

entonces

mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

ninguno funcionó ...


Si usar el css no resuelve su problema, puede intentar usar un TextView con fromHtml en lugar de usar una vista web:

TextView myTextView = (TextView) view.findViewById(R.id.my_textview); Spanned textviewHtml; //Note : fromHtml needs a display flag as second argument from API 24 if (Build.VERSION.SDK_INT >= 24) { textviewHtml= Html.fromHtml(yourHtmlHere, Html.FROM_HTML_MODE_COMPACT); } else { textviewHtml= Html.fromHtml(yourHtmlHere); } myTextView.setText(textviewHtml);

Para obtener más opciones sobre fromHtml, puede consultar https://developer.android.com/reference/android/text/Html.html

¡Espero que esto ayude! ;-)


Solo úselo * {margen: 0px; Relleno: 0px} Agrega tu hoja de estilos y verifica una vez

*{margin:0px; padding:0px} body,html{padding:0px;margin:0px;} <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">


Utilice el siguiente código para eliminar los márgenes al imprimir la vista web.

@page{ margin-left: 0px; margin-right: 0px; margin-top: 0px; margin-bottom: 0px; }