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

Create SingleImageToPdf transformer #24

Open
mykolamelnykml opened this issue Oct 28, 2024 · 0 comments
Open

Create SingleImageToPdf transformer #24

mykolamelnykml opened this issue Oct 28, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@mykolamelnykml
Copy link
Collaborator

mykolamelnykml commented Oct 28, 2024

Need to implement SingleImageToPdf transformer for convert single image to the single page pdf.

Please use img2pdf package.

It should have following params:

  • inputCol
  • outputCol
  • resolution

Please use HasOutputCol, HasInputCol, HasResolution classes. For example:

class SingleImageToPdf(Transformer, DefaultParamsReadable, DefaultParamsWritable, HasOutputCol, HasInputCol, HasResolution):

And should use following code for transform image to pdf:

imageResolution = image.resolution
if imageResolution == 0 or imageResolution is None:
imageResolution = 300
if self.getResolution() > 0:
imageResolution = self.getResolution()

width = image.width / imageResolution * self.POINTS_PER_INCH
height = image.height / imageResolution * self.POINTS_PER_INCH

a4inpt = (img2pdf.mm_to_pt(210), img2pdf.mm_to_pt(297))
layout_fun = img2pdf.get_layout_fun(a4inpt)
pdf_bytes = img2pdf.convert(io.BytesIO(image.data), layout_fun=layout_fun)

And create good test coverage for Spark and Local pipelines.

@mykolamelnykml mykolamelnykml converted this from a draft issue Oct 28, 2024
@mykolamelnykml mykolamelnykml added this to the 0.2.0 Release milestone Oct 28, 2024
@mykolamelnykml mykolamelnykml added the enhancement New feature or request label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

2 participants