Skip to content

Set imageableArea through options in PrintImage.#1410

Open
antoineveldhoven wants to merge 1 commit intoqzind:masterfrom
antoineveldhoven:image-set-page-imageable-area
Open

Set imageableArea through options in PrintImage.#1410
antoineveldhoven wants to merge 1 commit intoqzind:masterfrom
antoineveldhoven:image-set-page-imageable-area

Conversation

@antoineveldhoven
Copy link
Contributor

@antoineveldhoven antoineveldhoven commented Jan 30, 2026

Fixes #1413

Copilot AI review requested due to automatic review settings January 30, 2026 20:22

This comment was marked as spam.

@antoineveldhoven antoineveldhoven force-pushed the image-set-page-imageable-area branch from 62a2db3 to 872c954 Compare January 30, 2026 20:41
@antoineveldhoven antoineveldhoven marked this pull request as draft January 30, 2026 20:52
@antoineveldhoven
Copy link
Contributor Author

Converted to draft; awaiting test results, will come back on this next week.

@tresf
Copy link
Contributor

tresf commented Jan 30, 2026

Thanks! Curious why copilot is spamming our tracker though. I've never seen this before and it's certainly not welcome on our tracker. Copilot typed more than the original PR description, it's pollution is not welcome and I'll block if from the repository if it continues.

@tresf tresf requested a review from akberenz January 31, 2026 00:10
@tresf
Copy link
Contributor

tresf commented Jan 31, 2026

we would like to specify the imageable area for printing images on custom paper sizes.

Do you mind filing a bug report describing what you're trying to achieve so that we can approach this PR from the same perspective as you? Currently we support printing images at their natural DPI and scaled to fit the paper. I assume you want something in between. If you can provide a use-case (sample image, paper size and a description of what it's not doing correctly) that'll help considerably in accepting this.

With regards to the PR, it's simple enough and should be pretty quick to review and merge. I'll tag @akberenz for a second set of eyes as she's been predominantly in charge of the 2D printing changes. For example, I wouldn't expect to have to reassign the Paper object the way it's done, but it's a copy of the PDF code so maybe Paper passed by value.

@antoineveldhoven
Copy link
Contributor Author

we would like to specify the imageable area for printing images on custom paper sizes.

Do you mind filing a bug report describing what you're trying to achieve so that we can approach this PR from the same perspective as you? Currently we support printing images at their natural DPI and scaled to fit the paper. I assume you want something in between. If you can provide a use-case (sample image, paper size and a description of what it's not doing correctly) that'll help considerably in accepting this.

With regards to the PR, it's simple enough and should be pretty quick to review and merge. I'll tag @akberenz for a second set of eyes as she's been predominantly in charge of the 2D printing changes. For example, I wouldn't expect to have to reassign the Paper object the way it's done, but it's a copy of the PDF code so maybe Paper passed by value.

@tresf will do!
I probably have some time tomorrow to file a bug report with full details.

@antoineveldhoven
Copy link
Contributor Author

Thanks! Curious why copilot is spamming our tracker though. I've never seen this before and it's certainly not welcome on our tracker. Copilot typed more than the original PR description, it's pollution is not welcome and I'll block if from the repository if it continues.

This is an option I have enabled; will turn it off, at least for this repo. Sorry for spamming

@antoineveldhoven
Copy link
Contributor Author

@akberenz Thanks for your review and suggestions; let me do some testing regarding the scaling tomorrow.

@tresf
Copy link
Contributor

tresf commented Feb 2, 2026

Thanks! Curious why copilot is spamming our tracker though. I've never seen this before and it's certainly not welcome on our tracker. Copilot typed more than the original PR description, it's pollution is not welcome and I'll block if from the repository if it continues.

This is an option I have enabled; will turn it off, at least for this repo. Sorry for spamming

FWIW, I'm fine with the static code analysis (it did find a mistake after all), I just don't like a bot "summarizing" with more text than the PR, so please use as-needed, my response was probably overly harsh considering it caught a bug in the code changes.

@antoineveldhoven antoineveldhoven force-pushed the image-set-page-imageable-area branch from 872c954 to 4565766 Compare February 3, 2026 20:42
@antoineveldhoven
Copy link
Contributor Author

antoineveldhoven commented Feb 3, 2026

This PR aims to fix issue #1413

By supplying the size in the config we can specify the custom PageForm / ImageableArea.

const config = qz.configs.create(
      printer.model,
        {
            size: {
                // Force printer to use max width.
                width: printable.data.widthInch,
                height: printable.data.heightInch
            },
            scaleContent: false,
            units: 'in',
            density: printable.data.dpi
        }
    );
    const commands = [{
        type: "pixel",
        format: "image",
        flavor: "base64",
        data: printable.data.image,
        options: {
            pageWidth: printable.data.widthInch,
            pageHeight: printable.data.heightInch,
        }
    }];

    await qz.print(config, commands);

This results in the following image

afbeelding afbeelding

debugging job-object in PrintPixel.printCopies() method, just before job.print() shows that the ImageableArea is as large as the custom page size

@antoineveldhoven antoineveldhoven marked this pull request as ready for review February 3, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to set custom page size for printing images.

4 participants