Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print method seems to be accidentelly semi dropped from the api #356

Closed
tg-freigmbh opened this issue May 21, 2024 · 4 comments
Closed

print method seems to be accidentelly semi dropped from the api #356

tg-freigmbh opened this issue May 21, 2024 · 4 comments

Comments

@tg-freigmbh
Copy link

Hello,

Our Project needs org.icepdf.ri.common.print.PrintHelperImpl#print(java.awt.Graphics, java.awt.print.PageFormat, int)
In the current version of icepdf it seems like this method got somewhat hidden, PrintHelperImpl does implement Printable, but PrintHelper does not not implement Printable...
So it works when you instantiate the PrintHelperImpl directly, but you cant call print(java.awt.Graphics, java.awt.print.PageFormat, int) if you are using the PrintHelperFactoryImpl#createPrintHelper.
Not sure if thats intended, I was fairly confused by this.
Maybe make PrintHelper implement Printable ?

@pcorless
Copy link
Owner

As work around you could cast PrintHelperFactoryImpl#createPrintHelper to (PrintHelperImpl). But to your point the print(java.awt.Graphics, java.awt.print.PageFormat, int) probably should be defined as abstract in the base class or the base class implements Printable as you suggested. I'll have to think about this a bit, at the moment it's not clear to me if one approach is better then the other.

Can you provide any more detail as to why you are calling print(java.awt.Graphics, java.awt.print.PageFormat, int) directly, I'm curious as this usually done by the DocPrintJob ?

@tg-freigmbh
Copy link
Author

If I understand our spaghetti correctly: In "our" Printjob we put multiple printable things together (Plain-Text,Html, Graphics, and 1 or more pdfs . This gets done by passing the printgraphics around to each module/by using the Printable interface.
Using DocPrintJob seems like the better solution if all you want to do is printout the pdf document. However In our case the pdf is only part of a bigger printout.

@pcorless
Copy link
Owner

Thanks for the information. I think it would be best to have PrintHelper extend Printable so that you have a proper instance. I'll ready a PR for you to review.

pcorless added a commit that referenced this issue May 23, 2024
…jobs that are made up of different Doc types.
pcorless added a commit that referenced this issue May 25, 2024
pcorless added a commit that referenced this issue May 28, 2024
…jobs that are made up of different Doc types. (#357)
@pcorless
Copy link
Owner

Merged fix

pcorless added a commit that referenced this issue May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants