You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Sven Jeppsson (JIRA)" <ji...@apache.org> on 2018/01/21 09:18:00 UTC
[jira] [Updated] (PDFBOX-4073) Choosable Coordinate-Unitsystem
(mm,inches,...?)
[ https://issues.apache.org/jira/browse/PDFBOX-4073?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sven Jeppsson updated PDFBOX-4073:
----------------------------------
Priority: Minor (was: Critical)
> Choosable Coordinate-Unitsystem (mm,inches,...?)
> ------------------------------------------------
>
> Key: PDFBOX-4073
> URL: https://issues.apache.org/jira/browse/PDFBOX-4073
> Project: PDFBox
> Issue Type: New Feature
> Reporter: Sven Jeppsson
> Priority: Minor
> Attachments: unitconverter.patch
>
>
> Hey,
> I want to suggest a feature.
> I guess many people prefer to directly work with "mm" or "inches" instead of points. The common approach is to create an converter or ratio-Constant and convert at any place the "mm" or "inches" to points.
> I suggest an other approacher, what do you think about an central setting of an "unitconverter" so that every coordinate is converted deep inside shortly before rendering?
> I created a patch based on the 3.0.0-SNAPSHOT in [https://github.com/apache/pdfbox.git]
> I don't know the API enough to change all related Codelines. But this patch should give an Idea what i mean.
> For this approach I ignored:
> * that actually die "PDPage" mediabox shoud be converted too.
> * the Matrix arguments
>
> {code:java}
> // Usage example
> UnitConverter.activeConverter=UnitConverter.MM_CONVERTER;
> try (PDDocument doc = new PDDocument())
> {
> PDPage page = new PDPage(PDRectangle.A4); // works still unconverted
> doc.addPage(page);
>
> PDFont font = PDType1Font.HELVETICA_BOLD;
> try (PDPageContentStream contents = new PDPageContentStream(doc, page))
> {
> contents.beginText();
> contents.setFont(font, 12); //we are used to fontsizes, i would not use a converter here
> contents.newLineAtOffset(10, 10);// x=10mm,y=10mm
> contents.showText(message);
> contents.endText();
> }
>
> doc.save(filename);
> }
> {code}
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org