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

The Image size is altering when trying to Print 300 DPI in PDF #449

Open
Mahendershah opened this issue Mar 22, 2021 · 3 comments
Open

The Image size is altering when trying to Print 300 DPI in PDF #449

Mahendershah opened this issue Mar 22, 2021 · 3 comments
Labels

Comments

@Mahendershah
Copy link

Description

We have a image that is fixed size and is in 300 DPI. We want to add that image in the PDF. On doing so when we add the image in the PDF using Unidoc unipdf, the image overall size is reducing.

Expected Behavior

Since the size of the image and DPI is fixed i.e. DPI is 300 the size of the image in the output PDF should be of the same size as provided

Actual Behavior

Steps to reproduce the behavior:


pageSize := creator.PageSize{creator.PageSizeA4[0], creator.PageSizeA4[1]}
c.SetPageSize(pageSize)
c.NewPage()
img, err := getImage(c, imgPath, 22.2, 18.8, 80.35)
_ = c.Draw(img)
c.SetOptimizer(optimize.New(optimize.Options{
ImageQuality: 300,
ImageUpperPPI: 300,

}))

err = c.WriteToFile(outputPath)

The above bold text shows how we are specifying the Optimizer to create 300 DPI image.


func getImage(c *creator.Creator, imgPath string, x float64, y float64, w float64) (*creator.Image, error) {
img, err := c.NewImageFromFile(imgPath)
if err != nil {
common.Log.Debug("Error loading image: %v", err)
return nil, err
}

//var xx = float64(300 * 1.0 / 25.4)
new_x := x * creator.PPMM
new_y := y * creator.PPMM
new_w := w * creator.PPMM
img.ScaleToWidth(new_w)
img.SetPos(new_x, new_y)
return img, nil

}

Attachments

None

@github-actions
Copy link

Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized, other issues go into our backlog where they are assessed and fitted into the roadmap when suitable. If you need to get this done, consider buying a license which also enables you to use it in your commercial products. More information can be found on https://unidoc.io/

@Mahendershah
Copy link
Author

I am working for a company and we are having the license for use in commercial product.

@gunnsth
Copy link
Contributor

gunnsth commented Aug 1, 2021

Hi @Mahendershah I do not recall seeing this reported in our service desk? Was it filed there, and has this been resolved? Would be good to close.
There was a fix related to image optimization with PPI settings in the newest release https://github.com/unidoc/unipdf/releases/tag/v3.27.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants