我有一项活动可以选择并保存个人资料照片.有一个图像视图和一个按钮,用于启动图库活动以获得用户选择图像的结果.关闭图库时,将执行以下代码:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if ((resultCode == RESULT_OK) && (requestCode == SELECT_PHOTO)) {
Uri selectedImage = data.getData();
try {
Bitmap image = this.decodeAndScaleImage(selectedImage, 285);
imgInsertPicture.setImageBitmap(image);
this.imagePresent = true;
this.saveMyProfilePicture(image);
this.popImageView();
} catch (IOException e) {
e.printStackTrace();
showToast(R.string.error_saving_picture);
}
}
}
private void saveMyProfilePicture(Bitmap picture) throws IOException {
FileOutputStream outputStream = openFileOutput(Globals.MY_PICTURE_FILE_NAME, MODE_PRIVATE);
picture.compress(Globals.MY_PICTURE_FORMAT, 90, outputStream);
outputStream.close();
ByteArrayOutputStream rawOutputStream = new ByteArrayOutputStream();
picture.compress(Globals.MY_PICTURE_FORMAT, 90, rawOutputStream);
byte[] rawPictureData = rawOutputStream.toByteArray();
rawOutputStream.close();
byte[] …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 puppeteer 将带有多个 nvd3 图表的页面打印为 pdf。通过 Chrome 浏览器使用打印功能时,我获得了以下不错的输出(不要介意蓝色边框):
当我尝试通过 puppeteer 使用 chrome headless 访问同一页面时,我得到了这个输出,跨越 3 个页面:
这是我正在使用的代码:
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setCookie({
name: 'cookie-a',
value: '...',
domain: 'example.com'
});
await page.setCookie({
name: 'cookie-b',
value: '...',
domain: 'example.com'
});
await page.goto('http://example.com/search/?bookmark=bot-overview', {waitUntil: 'networkidle'});
setTimeout(async function () {
await page.pdf({ path: 'page.pdf', format: 'A4', landscape: true });
browser.close();
}, 10000);
})();
Run Code Online (Sandbox Code Playgroud)
我还尝试将高度和宽度固定为像素值、cm 和 mm,但它不会影响输出。请注意,整个页面都通过页面进行样式设置,并使用其印刷媒体样式表进行引导。我还为打印媒体添加了几个 css 规则(其中蓝色边框)。这些规则之一强制整个页面为 297mmx210mm 大,即 …
javascript google-chrome nvd3.js google-chrome-headless puppeteer