Skip Menu |

This queue is for tickets about the PDF-API2 CPAN distribution.

Report information
The Basics
Id: 132657
Status: open
Priority: 0/
Queue: PDF-API2

People
Owner: Nobody in particular
Requestors: aquilarubra [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Attachments


Subject: text appearing reversed
Date: Tue, 19 May 2020 13:14:47 +0200
To: bug-PDF-API2 [...] rt.cpan.org
From: Fabrizio del Tin <aquilarubra [...] gmail.com>
When opening an existing PDF in order to add text to it. the text will appear reversed. my $pdf = PDF::Builder->open($myfile); my $font = $pdf->corefont('Helvetica'); my $page = $pdf->openpage('1'); my $text = $page->text(); $page->mediabox('Letter'); $text->font($font, 40); # Set font to Helvetiva, 9pt (add by 4 to increase) $text->translate(200, 700); # Text start location for Corp chk box $text->text('Hello World!'); # Print "X" at 173,660 $text->textlabel(400, 500, $font, 56, "i'm in ur pdf", -rotate => 180); $pdf->saveas($outfile.pdf'); $pdf->end; Screenshot attached. [image: Screenshot from 2020-05-19 13-14-00.png]
Screenshot from 2020-05-19 13-14-00.png
Subject: Re: [rt.cpan.org #132657] AutoReply: text appearing reversed
Date: Tue, 19 May 2020 13:43:47 +0200
To: bug-PDF-API2 [...] rt.cpan.org
From: Aquila Rubra <aquilarubra [...] gmail.com>
To add a detail, the PDF I was opening is generated by Chrome.
If this is Chrome output to PDF with annotations (page numbers, etc.), I've found that Chrome does something weird. It creates its text with a reversed and flipped coordinate system, and then proceeds to write individual items with corrected coordinates. Unfortunately, it leaves the text coordinate system in this strange state at the end of the object, and inserting a new text object picks up the bad coordinate system. This is clearly a Chrome bug. It's easy enough to compensate for this. See PDF::Builder::Content "Advanced Methods" documentation for how to do this.
Subject: Re: [rt.cpan.org #132657] text appearing reversed
Date: Tue, 19 May 2020 16:09:13 +0200
To: bug-PDF-API2 [...] rt.cpan.org
From: Aquila Rubra <aquilarubra [...] gmail.com>
That was it, thanks!
I hope you were able to fix it with that information. Actually, "bug" in Chrome may be a bit harsh. They apparently use a 3300 pixel high page with 0,0 at the top left and growing downwards. I guess they want to use this for other purposes than just PDF generation. Anyway, they leave it in that flipped, scaled state at the end of the object -- possibly to allow for more content to be added. The burden falls on you to cancel out this strange coordinate system and use something friendlier to PDF. I suppose they could have wrapped their entire object in q..Q, as they're the one writing content, but for whatever reason, they chose not to.
Subject: Re: [rt.cpan.org #132657] text appearing reversed
Date: Wed, 20 May 2020 04:07:14 +0200
To: bug-PDF-API2 [...] rt.cpan.org
From: Aquila Rubra <aquilarubra [...] gmail.com>
Yes, I could fix it. I had to repeat the fix for every page and it outputs the correct page size. Even the font size of the added text appears correct now (before the fix, I needed to use a much bigger size to obtain same). As I also needed to suppress header/footer -another weird thing, apparently working better in Chromium than Chrome - I ended up generating a smaller PDF in height (width can be controlled via the @page margin, then adding the missing margin via PDF::Api2. On May 20, 2020 1:03:09 AM GMT+02:00, "Phil M. Perry via RT" <bug-PDF-API2@rt.cpan.org> wrote: Show quoted text
><URL: https://rt.cpan.org/Ticket/Display.html?id=132657 > > >I hope you were able to fix it with that information. > >Actually, "bug" in Chrome may be a bit harsh. They apparently use a 3300 pixel high page with 0,0 at the top left and growing downwards. I guess they want to use this for other purposes than just PDF generation. Anyway, they leave it in that flipped, scaled state at the end of the object -- possibly to allow for more content to be added. The burden falls on you to cancel out this strange coordinate system and use something friendlier to PDF. I suppose they could have wrapped their entire object in q..Q, as they're the one writing content, but for whatever reason, they chose not to.