Open thiagomachado1998 opened 3 months ago
I managed to solve this lack of padding support for android in the following way :
access the following library folder : node_modules / react-native-html-to-pdf / android/src/java / android / pdfConverterJava search for this class below and configure the values according to your wishes :
private PrintAttributes getDefaultPrintAttrs() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return null;
return new PrintAttributes.Builder()
.setMediaSize(PrintAttributes.MediaSize.ISO_A4)
.setResolution(new PrintAttributes.Resolution("RESOLUTION_ID", "RESOLUTION_ID", 600, 600))
.setMinMargins(new PrintAttributes.Margins(
30, // padding Left
60, // padding top
30, // padding rigth
60 // padding bottom
))
.build();
}
then go to another folder with directory : node_modules / react-native-html-to-pdf / android / src / java / android / com / reactNativePDFmoduleJava look for this class below and replicate it the same way you customized the first class above: PrintAttributes pagesize=null; if(options.hasKey(HEIGHT) && options.hasKey(WIDTH)) { pagesize=new PrintAttributes.Builder() .setMediaSize(PrintAttributes.MediaSize.ISO_A4) .setResolution(new PrintAttributes.Resolution("RESOLUTION_ID", "RESOLUTION_ID", 600, 600)) .setMinMargins(new PrintAttributes.Margins( 30, // padding left 60, // padding top 30, // padding rigth 60 // padding bottom )) .build(); } your pdf will be generated with padding on each page
or you can add css style for html content to padding
i need each page of my pdf to have a padding top and padding bottom, but this feature is exclusive to ios, is there any alternative or change to the source code to change this?