ObjectProfile / Roassal3Exporters

PDF Exporter for Roassal3
MIT License
8 stars 3 forks source link

export as pdf and unit #2

Closed bergel closed 1 year ago

bergel commented 4 years ago

@pavel-krivanek said:

we can set the paper size by setting the canvas size but the ratio is somehow strange. 100 units = 1.398" = 35.5092 mm. More explicit and clean units management would be nice.

akevalion commented 4 years ago

I have a canvas 500@500 what is the expected result? to handle that?

canvas pdfExporter fileName: 'test'; export

What should be the correct size for test.pdf?

Because the info, resolution is 500x500 image.

https://support.activepdf.com/hc/en-us/articles/360002401633-What-are-PDF-Units-and-Coordinates-#:~:text=Space%20in%20a%20PDF%20file,units%20by%20792%20PDF%20units.

I read this web page then I think I can set the canvas extent in order to use inches, millimeters or pdf units.

pavel-krivanek commented 4 years ago

The PPI value should be configurable, as default value I would select standard 96 PPI. So 132.291667 millimeters in this case.

akevalion commented 4 years ago

What is ppi?

akevalion commented 4 years ago

Roassal exporters now use https://github.com/zweidenker/Units Consider the following script with the last version of Roassal3Exporters

c := RSCanvas new.

lbls := RSGroup new.
Collection withAllSubclassesDo: [ :cls |
    lbl := RSLabel new text: cls name; model: cls.
    lbls add: lbl ].
c addAll: lbls.

RSNormalizer fontSize
    shapes: lbls;
    normalize: #numberOfMethods.

"RSHierarchyPacker  on: lbls."
c @ RSCanvasController.
c @ RSHierarchyPacker.

c extent: (RSPageExtent from: 8.26 inches@ 11.69 inches).
c pdfExporter
    fileName: 'test';
    export.

image

RSPDFExporter uses unit point to export and create the pdf file. 1 point = 1/72 inch You will need to change the canvas extent in order to create a pdf document.

Use RSPageExtent, to correctly set the canvas extent before the export process. You can access a default values for well known pages sizes. RSPageExtent letter or RSPageExtent a4.

What do you think about it?

pavel-krivanek commented 4 years ago

PPI = pixels per inch. Very nice, it would be actually great to support the units even on the canvas level so you could draw lines with explicit extents in millimetres (for example) without need to recompute.

From where the value 72 comes from?

akevalion commented 4 years ago

It is an standard, I think we can not use units in roassal, because of the camera, with roassal camera you can adjust your visualization to the desire size.

Then is better use units in the canvas extent instead of each shape's coordinates

https://cairographics.org/manual/cairo-PDF-Surfaces.html#cairo-pdf-surface-create

tinchodias commented 4 years ago

I was also curious about the 1/72 and found interesting info in this wiki page.

May be not useful for the discussion, but I can add what I understand from the low-level PDF Cairo surface: The function caller always implicitly uses such 1/72 inch points.

For example, if you want to create an horizontal line of 1 inch in a A4 page, you can do this:

Well, I hope it doesn't darkens more than it cleans.

akevalion commented 4 years ago

Roassal3 PDF now uses units, can we close this issue?

akevalion commented 1 year ago

done