Open joaocardosoit opened 2 weeks ago
We were unable to reproduce the reported issue, the "test-with_margins_output.pdf" is generated as expected" and share the working samples with output generated from our side. Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/pdf_demo_sample_17514949949.zip Output: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Output-1989656091.zip
I uploaded the wrong input file to reproduce the reported issue. To do this, you must use this file: test_with_margins.pdf
We were able to reproduce the reported issue with the provided details on our end, and currently we are analyzing it. We will provide further details on May 8th, 2024.
We have confirmed the issue ”Preservation issue occurs when drawing in the page graphics in specific PDF document” as a defect in our product and fix will be included in our upcoming weekly release, which will be available on May 21, 2024.
Use the below feedback link to track the status of the reported bug.
Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”
Bug description
I'm using syncfusion_flutter_pdf: ^25.1.42
My issue is related to different behaviours of coordinates when drawing on existing pages of existing pdfs. Example when drawing a square at the coordinate position (0,0) in 2 PDFs:
In the first PDF (test_without_margins_input.pdf) the square is correctly drawn at the position (0,0)
In the second one (test_with_margins_input.pdf) the square is drawn with an unexpected offset on the x-axis, as if a margin had been set on the X axis. But no margin was set and the output of
page.size
andpage.getClientSize
gives the same dimensions (according to documentation, means that there are no margins in the PDF). For this example, the expected was to the square to be drawn at position (0,0) or topage.getClientSize
to show a diferent result thanpage.size
.Steps to reproduce
Code sample
Code sample
```dart import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:path_provider/path_provider.dart'; import 'package:syncfusion_flutter_pdf/pdf.dart'; Future> pdfAddRectangle(String filePath) async { final ByteData data = await rootBundle.load(filePath); final document = PdfDocument(inputBytes: data.buffer.asUint8List()); final page = document.pages[0]; debugPrint("File: $filePath"); debugPrint("Page size: ${page.size.width} x ${page.size.height}"); debugPrint("Page client size: ${page.getClientSize().width} x ${page.getClientSize().height}"); page.graphics.drawRectangle( pen: PdfPen( PdfColor(256, 0, 0), width: 2, ), bounds: const Rect.fromLTWH(0, 0, 200, 200), ); var saveDoc = await document.save(); document.dispose(); return saveDoc; } ```
Screenshots or Video
Screenshots / Video demonstration
##### 1st PDF output (ok) ![test_without_margins pdf_page-0001](https://i.postimg.cc/BncwjTSZ/test-without-margins-pdf-page-0001.jpg) ##### 2nd PDF output (issue) ![test_with_margins pdf_page-0001.png](https://i.postimg.cc/KvfTcJLG/test-with-margins-pdf-page-0001.jpg)Files
- 1st pdf - INPUT: [test_without_margins_input.pdf](https://github.com/syncfusion/flutter-widgets/files/15190754/test_without_margins.pdf) - 2nd pdf - INPUT: [test_with_margins_input.pdf](https://github.com/syncfusion/flutter-widgets/files/15190759/test_with_margins.pdf) - 1st pdf - OUTPUT: [test_without_margins_output.pdf](https://github.com/syncfusion/flutter-widgets/files/15190761/test_without_margins_output.pdf) - 2nd pdf - OUTPUT: [test_with_margins_output.pdf](https://github.com/syncfusion/flutter-widgets/files/15190763/test_with_margins_output.pdf)Stack Traces
Stack Traces
```dart [Add the Stack Traces here] ```On which target platforms have you observed this bug?
Android, iOS
Flutter Doctor output
Doctor output
```console [✓] Flutter (Channel stable, 3.19.2, on macOS 13.6 22G120 darwin-arm64, locale en-PT) • Flutter version 3.19.2 on channel stable at /Users/joaocardoso/src/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7482962148 (9 weeks ago), 2024-02-27 16:51:22 -0500 • Engine revision 04817c99c9 • Dart version 3.3.0 • DevTools version 2.31.1 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/joaocardoso/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) • All Android licenses accepted. [!] Xcode - develop for iOS and macOS (Xcode 15.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15C65 ✗ Unable to get list of installed Simulator runtimes. • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) [✓] VS Code (version 1.85.1) • VS Code at /Users/joaocardoso/Downloads/Visual Studio Code.app/Contents • Flutter extension version 3.88.0 [✓] Connected device (3 available) • iPhone de João (mobile) • 00008101-000828262110001E • ios • iOS 17.4.1 21E236 • macOS (desktop) • macos • darwin-arm64 • macOS 13.6 22G120 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.118 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. ```