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

Have the README show setting the page media-box with standard paper sizes [feature request] #5

Closed
tbrowder opened this issue Apr 15, 2023 · 7 comments

Comments

@tbrowder
Copy link

Also demonstrate user access to the default (portrait) paper dimensions and to the dimensions for landscape orientation.

@tbrowder tbrowder changed the title Have the README show how to set media-box with standard paper sizes [feature request] Have the README show settin the page media-box with standard paper sizes [feature request] Apr 15, 2023
@tbrowder tbrowder changed the title Have the README show settin the page media-box with standard paper sizes [feature request] Have the README show setting the page media-box with standard paper sizes [feature request] Apr 15, 2023
@tbrowder
Copy link
Author

I'm closing this for now. I may submit a PR.

@tbrowder tbrowder reopened this Apr 15, 2023
@tbrowder
Copy link
Author

I will be glad to submit a PR to demo some of this. Using PDF::Lite I have been able to read and set the media-box coords individually and also use .to-landscape on it.

However, I still need to be able to use the Content::PaperSizes to set the media-box but haven't yet been able to so so.

@tbrowder
Copy link
Author

I see how now. Closing this again and I will submit a PR later.

@tbrowder
Copy link
Author

I copied the following from PDF::Document::Page into my top-level working directory:

# Copied from PDF::Content
my subset Box of List is export where {.elems == 4}
sub to-landscape(Box $p --> Box) is export {
	[ $p[1], $p[0], $p[3], $p[2] ]
}
# These are the standard paper names and sizes copied from PDF::Content
my Array enum PageSizes is export <<
     ...
>>;

Then I wrote a new sub:

sub set-media-box(PDF::Content::Page :$page!, 
                  Str :$Media!, 
                  :$landscape = 0
) is export {
    die "FATAL: Media '' is not known in enum 'PageSizes'"
        unless %(PageSizes.enums){$Media}:exists;
    if $landscape {
        $page.media-box[] = to-landscape(PageSizes.enums{$Media});
    }
    else {
        $page.media-box[] = PageSizes.enums{$Media};
    }
}

That works for me for now. Elevating those PDF::Content vars to be accessible from PDF::Lite would ease the pain.

@tbrowder tbrowder reopened this Apr 15, 2023
@tbrowder
Copy link
Author

OBE

@jubilatious1
Copy link

Very nice! Will test soon.

@tbrowder
Copy link
Author

Better to see the open issue here where I have a corrected script that doesn't yet rely on my modules.

BTW, my email is 'tom.browder@gmail.com' if you'ld like to communicate more directly. Since you're apparently the only person who is interested in my PDF modules, I could use answers to the following:

  • What country are you from?
  • If not the USA:
    • What Google Nota font language selections would you like me to provide for use with my modules?
    • What standard paper sizes do you use?

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