JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.15k stars 1.17k forks source link

how can print jetpack compose canvas in windows desktop app or print any jetpack UI like LazyColumn #1585

Closed helmysaeed closed 2 years ago

helmysaeed commented 2 years ago

how can print jetpack compose canvas in windows desktop app or print any jetpack UI like LazyColumn

akurasov commented 2 years ago

I'm sorry, I don't understand what do you want to do

kirill-grouchnikov commented 2 years ago

Probably something like https://docs.oracle.com/javase/tutorial/2d/printing/index.html

helmysaeed commented 2 years ago

w

Probably something like https://docs.oracle.com/javase/tutorial/2d/printing/index.html

it does not support jetpack compose like canvas

helmysaeed commented 2 years ago

I'm sorry, I don't understand what do you want to do

I need to print Invoice created by jetpack compose canvas or print lazyColumn directly like when print canvas in android

kirill-grouchnikov commented 2 years ago

My comment was not to suggest that Java2D printing somehow magically works for a completely different toolkit that is Compose. It was to clarify the request.

Probably given the multi-platform aspirations of this framework, the simplest would be to provide a functionality to export canvas content to a PDF and have the underlying platform handle the PDF-to-print pipeline.

helmysaeed commented 2 years ago

My comment was not to suggest that Java2D printing somehow magically works for a completely different toolkit that is Compose. It was to clarify the request.

Probably given the multi-platform aspirations of this framework, the simplest would be to provide a functionality to export canvas content to a PDF and have the underlying platform handle the PDF-to-print pipeline.

@kirill-grouchnikov thank you

akurasov commented 2 years ago

Currently there is no such possibility. What probably could be tried is the following:

  1. Create test Window with the same content
  2. Grab its bitmap
  3. Find some java printing engine that accepts bitmap and pass the bitmap to it

Steps 1-2 are described in https://github.com/JetBrains/compose-jb/issues/368

mcpiroman commented 2 years ago

Couldn't ComposeScene be used? With it you can draw to canvas instead of window.

okushnikov commented 3 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.