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

US Letter has incorrect size #847

Open
grinay opened this issue Apr 7, 2024 · 2 comments
Open

US Letter has incorrect size #847

grinay opened this issue Apr 7, 2024 · 2 comments
Assignees

Comments

@grinay
Copy link

grinay commented Apr 7, 2024

Hello. I'm trying to create pdf out of json file.
I'm looking for a way to set the custom page size, but unable to find it and start looking into standard sizes provided with parameter paper. And I found what I'm looking for. Format "Letter", however standard of letter has dimensions of 612x792 but in pdfcpu it has size 612x791. May you advice is that a bug?
And is there any way to set the custom size?

Also would be interesting to know, how to set media box.

Here is my json

{
  "origin": "UpperLeft",
  "paper": "Letter",
  "pages": {
    "1": {
      "paper": "Letter",
      "content": {
        "paper": "Letter",
        "width": 612,
        "height": 792,
        "image": [
          {
            "src": "image.png",
            "pos": [
              0,
              0
            ],
            "width": 612,
            "height": 792
          }
        ]

and later there is only pure text create with absolute position.
And in log I see

WRITE: 2024/04/07 15:16:11 writePagesDict: writing pageDict for obj=2 page=1
<<
        <Count, 1>
        <Kids, [(6 0 R)]>
        <MediaBox, [0.00 0.00 595.00 842.00]>
        <Type, Pages>
>>
WRITE: 2024/04/07 15:16:11 addToObjectStream begin, obj#:2 gen#:0
TRACE: 2024/04/07 15:16:11 FindTableEntry: obj#:8 gen:0 
TRACE: 2024/04/07 15:16:11 FindTableEntry: obj#:2 gen:0 
TRACE: 2024/04/07 15:16:11 AddObject end : ObjCount:3 prolog = <6 0 4 243 2 315> Content = <<</Contents 5 0 R/CropBox[0.000000000000 0.000000000000 612.000000000000 791.000000000000]/MediaBox[0.000000000000 0.000000000000 612.000000000000 791.000000000000]/Parent 2 0 R/Resources<</Font<</F0 4 0 R>>/XObject<</Im0 3 0 R>>>>/Type/Page>><</BaseFont/Helvetica/Encoding/WinAnsiEncoding/Subtype/Type1/Type/Font>><</Count 1/Kids[6 0 R]/MediaBox[0.000000000000 0.000000000000 595.000000000000 842.000000000000]/Type/Pages>>>

I don't understand where is this media box comes from <MediaBox, [0.00 0.00 595.00 842.00]>, as I have another sizes. I'm trying to solve the issue of correctly positioning text, but my text for some reasons misaligned originally it must be around 15 point lower, trying to recreate pdf after OCR.

@grinay
Copy link
Author

grinay commented Apr 7, 2024

Small update, I was able to put text on its place by adding height into Y position.
The only questions left about the custom sizes, and media boxes.

@hhrutter
Copy link
Collaborator

hhrutter commented Apr 8, 2024

papersize is corrected.
thanks for discovering this!

As far as the PDF creation via JSON:
Did you check the samples at https://github.com/pdfcpu/pdfcpu/tree/master/pkg/testdata/json/create ?

@hhrutter hhrutter reopened this Apr 8, 2024
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

2 participants