DavBfr / dart_pdf

Pdf creation module for dart/flutter
https://pub.dev/packages/pdf
Apache License 2.0
1.39k stars 625 forks source link

RawImage is cropped when using --web-renderer html #1278

Closed johannesstricker closed 1 year ago

johannesstricker commented 1 year ago

Describe the bug When the html web-renderer is used, the RawImage widget scales and crops the underlying image, when the browser window is zoomed.

I first noticed this, when visiting my app on an iPad with Safari. I guess that's because the iPad screen has higher dpi? Then I tried to reproduce it on my MacBook and was able to do so, when zooming in in Chrome.

To Reproduce Code snippet to reproduce the behavior:

import 'dart:ui' as ui;
import 'package:pdf/widgets.dart' as pw;

Future<pw.Image> createImageWidget(ui.Image image) {
  final bytes = await image.toByteData();
  final rawImage = pw.RawImage(
    bytes: bytes!.buffer.asUint8List();
    width: image.width,
    height: image.height,
  );
  return pw.Image(rawImage);
}

Expected behavior This is what above code produces when using the canvaskit renderer (and 125% scale in Chrome). image

This is how it looks with html renderer at 100% scale in Chrome. image

Screenshots And this is how it looks with html renderer and 125% zoom. image

Flutter Doctor

[✓] Flutter (Channel stable, 3.7.3, on macOS 12.6 21G115 darwin-arm64, locale en-GB)
    • Flutter version 3.7.3 on channel stable at /Users/johannesstricker/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9944297138 (3 weeks ago), 2023-02-08 15:46:04 -0800
    • Engine revision 248290d6d5
    • Dart version 2.19.2
    • DevTools version 2.20.1

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for
      detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from
      https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for
      detailed instructions).

[✓] VS Code (version 1.75.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.58.0

[✓] Connected device (4 available)
    • iPad von Johannes (mobile)                   • 00008103-001620603460C01E
      • ios            • iOS 16.2 20C65
    • iPad Pro (11-inch) (4th generation) (mobile) • 691C391C-6BC9-49D2-96EB-FACE582E4E2F
      • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
    • macOS (desktop)                              • macos
      • darwin-arm64   • macOS 12.6 21G115 darwin-arm64
    • Chrome (web)                                 • chrome
      • web-javascript • Google Chrome 110.0.5481.177

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 2 categories.

Desktop (please complete the following information): Tested on:

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

johannesstricker commented 1 year ago

bump

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] commented 1 year ago

Closing this stale issue because it has no activity.

johannesstricker commented 7 months ago

This is still an issue in the current release.

environment:
  sdk: '>=3.0.0 <4.0.0'
  flutter: '3.16.9'

dependencies:
  pdf: 3.10.7
  printing: 5.11.1