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

Is it possible to increase margin on one side? #4

Closed
hugolundin opened this issue Jul 20, 2017 · 10 comments
Closed

Is it possible to increase margin on one side? #4

hugolundin opened this issue Jul 20, 2017 · 10 comments
Assignees

Comments

@hugolundin
Copy link

I want to scale a PDF and left-align the original content. Is this possible?

@tavinus
Copy link
Owner

tavinus commented Jul 23, 2017

Hi!
This is not supported at this point but I may try to fit it in.
The scaling sets an offset based on some calculations comparing the base size and target size to center the page. To left-align I guess you would still want some margin on the left size, but a fixed one right? Not sure, but I guess we would need a fixed left margin and then the right margin gets what is left from the paper size. Ideas welcome...

@tavinus tavinus self-assigned this Jul 23, 2017
@tavinus
Copy link
Owner

tavinus commented Jul 24, 2017

Ok, so the way it is centered in scaling mode is by setting the Translation X and Y at the scale call which is injected into the new PDF. I am guessing we would need to fix the translation X to some arbitrary postscript-points (we could use mm and inches and transform them if needed as well, since that is already implemented).

However, I am not sure this would work fine in all cases. I will test it to see how it performs.

@tavinus
Copy link
Owner

tavinus commented Jul 24, 2017

Makes me wonder if what you want is just to keep everything in place?
I mean, maybe just removing the translation call could do that, but I am not sure. If that is the case we would need just a flag like --keep-position that would remove the translation from the command.

Or we could add/remove points from the calculated translations (which are based on the scaling factor).

Or we could add a <</PageOffset [-72 0]>> at the setpagedevice call after the scale/translate call. But I am not sure these would work properly together.

Some references:

@tavinus
Copy link
Owner

tavinus commented Jul 24, 2017

So, would it work for you if the content was kept in place (top-left corner) when scaling?
Or would you actually want to just left-align your pages (without actually scaling it)?
Honestly I am not 100% sure on the top-left, but think it stays there. I think it is either there or bottom-right but I will test it to make sure. This will require a lot of testing, but the problem is that I am not sure I understand what you are trying to do.

@masgo
Copy link

masgo commented Mar 21, 2018

Hi, I have a very similar problem: I want to gain whitespace on one side of the paper by shrinking the content. Currently the content is shrunken and centered. So, If I shrink it by 6%, I have 3% whitespace on either side. If it would be possible to push the shrunken content to the border, I would have the 6% space on one side and therefore enough margin for my needs.

@tavinus
Copy link
Owner

tavinus commented Apr 1, 2018

I see.
That may be the better way to do it.
I mean setting percentages for each 4 sides and also offer some presets (top-left for example).
Zero-margin may be too agressive (almost a crop), so a flag for that may also be needed.

I will try to find the time to address this soon.
Cheers!

@tavinus tavinus mentioned this issue Apr 1, 2018
@tavinus
Copy link
Owner

tavinus commented Apr 1, 2018

Hi!
I have pushed some changes on a new release - v2.2.0

This one makes possible to reposition the PDF:

  • Vertical : top/bottom/center
  • Horizontal : left/right/center
  • xoffset to move horizontally (in points)
  • yoffset to move vertically (in points)

Offset makes possible to fine-tune on top of the base positioning.
So you can position at top-left and then fine-tune it with offsetting, for example.

Please let me know if that solves your problem.
The release notes and the --help option explain the new functionality.

Edit 1: v2.2.1 with yet more changes is out!

Edit 2: Please note that GS anchors on bottom-left. It may be a bit weird to adjust the x/y offsets because of that. Play a bit with positive/negative x/y offsets so you can understand how it works and then position the PDF where you want it to be. You can certainly use both vert/hor alignment and x/y offseting together.

Cheers!
Gus

@tavinus tavinus added the fixed-waiting-feedback Fix Pushed! Waiting for feedback to close! label Apr 1, 2018
@BryanEllis
Copy link

Using the new xtrans/ytrans features I was able to move my page content changing the margins. It is really great.

@hugolundin
Copy link
Author

Awesome! I solved this problem using another library, however what you have done seem to solve the original problem. Should I close the issue?

@tavinus
Copy link
Owner

tavinus commented Apr 1, 2018

Cool! Glad to know! 👍
Sorry I could not tackle this before.

v2.3.0 is out BTW

Cheers!
Gus

@tavinus tavinus closed this as completed Apr 1, 2018
@tavinus tavinus removed the fixed-waiting-feedback Fix Pushed! Waiting for feedback to close! label Apr 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants