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

Fix PDF scaling #251

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

Joshmul1
Copy link

@Joshmul1 Joshmul1 commented Jun 11, 2024

Fixes #250

Copy link
Collaborator

@primo-ppcg primo-ppcg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is converting to the nearest inch actually the correct behavior? Many label sizes are not exact multiples of an inch (e.g. 4" x 6.5").

@Joshmul1
Copy link
Author

Good point, I'm not sure why I went down the rabbit hole of using an int specifically.
I've updated the PR to handle it as a float and I've tested random inch values and it seems to be good

@primo-ppcg
Copy link
Collaborator

The scaling doesn't appear to be correct in all cases. Examples 5, 6, and 8 in the WebViewer are all cropped - this is not the case with the current release.

@Joshmul1
Copy link
Author

It works for lots of different sizes but then some render with whitespace on the right as the canvas we're drawing on is too small.
This is all new territory for me so I can have a mess around with it to try figure out what is going on.

Do you have any initial ideas on what could be causing it to be strange on some sizes?

@Joshmul1
Copy link
Author

Joshmul1 commented Jun 13, 2024

I've misunderstood the issue you reported earlier. When I use the web api, labeleray and my branch I get the same results on them all.

Can you please give me more info on the issue you're seeing so I can try replicate it?

@primo-ppcg
Copy link
Collaborator

primo-ppcg commented Jun 14, 2024

Can you please give me more info on the issue you're seeing so I can try replicate it?

This is the result of the PDF output for Example 5 with your patch applied (as viewed with Acrobat Reader):
example5

@Joshmul1
Copy link
Author

Done some more playing around with that particular example and I'm struggling to know what I'm needing to do to debug or fix the issue. I might need some help on this one.

The fix I made does work for a large amount of labels so I can use it for my purposes without issue until someone else can give insight or a solution on the issue.

@primo-ppcg
Copy link
Collaborator

From what it seems, not all elements are being scaled equally. From the example 5, the graphics boxes appear to be scales, but the text and barcodes are not.

@danzk
Copy link
Contributor

danzk commented Jun 19, 2024

From what it seems, not all elements are being scaled equally. From the example 5, the graphics boxes appear to be scales, but the text and barcodes are not.

I believe all the elements should scale after merging my most recent PR. I observed the same issue when trying to scale a canvas passed into the ZplElementDrawer. It is because text and barcodes element drawer clear any scaling applied with the following code.

//Clears the existing rotation or scale applied to the canvas. 
if (matrix != SKMatrix.Empty)
{
    this._skCanvas.SetMatrix(matrix);
}

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

Successfully merging this pull request may close these issues.

DrawPdf not honouring width and height input
3 participants