trevorsandy / lpub3d

An LDraw™ editor for LEGO® style digital building instructions.
https://trevorsandy.github.io/lpub3d/
136 stars 19 forks source link

PDF Mixed Page Orientation Incorrect #59

Closed d-j-m-0 closed 6 years ago

d-j-m-0 commented 6 years ago

PDF generated by LPub3D has incorrect page orientations

When a mpd file contains multiple page orientations (i.e. landscape and portrait), although LPub3D displays them (mostly) with the correct orientation, the resulting generated PDF file has incorrect page orientations.

Your environment

Configuration

Logs

N/A

Screenshots

Steps to reproduce

  1. Rename the attached file from landscape_portrait_mpd.txt to landscape_portrait.mpd landscape_portrait_mpd.txt
  2. Open the attached mpd file landscape_portrait.mpd using LPub3D
  3. Page through the file. The third page is shown with a portrait page orientation. All other pages are shown with a landscape page orientation. This is as expected.
  4. Export the instructions to a PDF file
  5. Open the PDF file. All pages have a portrait orientation (as per attached PDF). landscape_portrait.pdf

Additional comment: The parts list on the page with the portrait orientation is placed off to the left of the page within LPub3d. Refer to the attached screenshot. landscape_portrait

Expected behaviour

In the PDF, only the third page should have a portrait orientation. All other pages should have a landscape orientation. In LPub3D, the parts list on the portrait page should appear on the page.

Actual behaviour

All pages in the PDF have a portrait orientation.

Workaround

Unknown.

Solution suggestion

Unknown.

trevorsandy commented 6 years ago

Yep - some strange stuff going on here. Working on it now...

trevorsandy commented 6 years ago

Corrected.

trevorsandy commented 6 years ago

I've addressed both bugs described in this issue.

  1. Mixed page orientation export does not output a mixed orientation file.
  2. Mixed page orientation display positions the PLI outside the page bounds - see 'Additional comments' above.

Additionally, I've refactored the the page size routines with improved robustness and flexibility. Notably, it is no longer necessary to define both page width and height dimensions (e.g. 8.2677 x 11.6929) and the page size ID (e.g. A4), as in the first example below. Defining either will suffice, as in the second and third examples below. Any of the below page size definitions are now valid:

0 !LPUB PAGE SIZE GLOBAL 8.2677 11.6929 A4
0 !LPUB PAGE SIZE GLOBAL 8.2677 11.6929
0 !LPUB PAGE SIZE GLOBAL A4

Custom size definitions must include width, height and "Custom" as the size ID. For example
0 !LPUB PAGE SIZE GLOBAL 12.1234 15.5678 Custom

As before, it is not necessary to include a PAGE SIZE meta when changing the page orientation. Only the page orientation meta e.g 0 !LPUB PAGE ORIENTATION GLOBAL LANDSCAPE is necessary.

Also page width and height dimensions should always be defined in the order width then height. DO NOT flip the width and height dimensions to change the page orientation.

Here is the complete list of supported page size IDs and their respective width and height dimensions in centimeters and inches:

SIZE ID      W(cm)    H(cm)     W(in)    H(in)
A0        =  84.1000  118.9000  33.1102  46.8110
A1        =  59.4000   84.1000  23.3858  33.1102
A2        =  42.0000   59.4000  16.5354  23.3858
A3        =  29.7000   42.0000  11.6929  16.5354
A4        =  21.0000   29.7000   8.2677  11.6929
A5        =  14.8000   21.0000   5.8268   8.2677
A6        =  10.5000   14.8000   4.1339   5.8268
A7        =   7.4000   10.5000   2.9134   4.1339
A8        =   5.2000    7.4000   2.0472   2.9134
A9        =   3.7000    5.2000   1.4567   2.0472
A10       =   2.6000    3.7000   1.0236   1.4567
ArchA     =  22.8600   30.4800   9.0000  12.0000
ArchB     =  30.4800   45.7200  12.0000  18.0000
ArchC     =  45.7200   60.9600  18.0000  24.0000
ArchD     =  60.9600   91.4400  24.0000  36.0000
ArchE     =  91.4400  121.9200  36.0000  48.0000
ArchE1    =  76.2000  106.6800  30.0000  42.0000
ArchE2    =  66.0400   96.5200  26.0000  38.0000
ArchE3    =  68.5800   99.0600  27.0000  39.0000
AnsiA     =  21.5900   27.9400   8.5000  11.0000
AnsiB     =  27.9400   43.1800  11.0000  17.0000
AnsiC     =  43.1800   55.8800  17.0000  22.0000
AnsiD     =  55.8800   86.3600  22.0000  34.0000
AnsiE     =  86.3600  111.7600  34.0000  44.0000
B0        = 100.0000  141.4000  39.3701  55.6693
B1        =  70.7000  100.0000  27.8346  39.3701
B2        =  50.0000   70.7000  19.6850  27.8346
B3        =  35.3000   50.0000  13.8976  19.6850
B4        =  25.0000   35.3000   9.8425  13.8976
B5        =  17.6000   25.0000   6.9291   9.8425
B6        =  12.5000   17.6000   4.9213   6.9291
B7        =   8.8000   12.5000   3.4646   4.9213
B8        =   6.2000    8.8000   2.4409   3.4646
B9        =   4.4000    6.2000   1.7323   2.4409
B10       =   3.1000    4.4000   1.2205   1.7323
Comm10E   =  10.5000   24.1000   4.1339   9.4882
DLE       =  11.0000   22.0000   4.3307   8.6614
Executive =  18.4150   26.6700   7.2500  10.5000
Folio     =  21.0000   33.0000   8.2677  12.9921
Ledger    =  43.1800   27.9400  17.0000  11.0000
Legal     =  21.5900   35.5600   8.5000  14.0000
Letter    =  21.5900   27.9400   8.5000  11.0000
Tabloid   =  27.9400   43.1800  11.0000  17.0000
Custom    =   0.0000    0.0000   0.0000   0.0000