Open mibieri opened 6 years ago
From what I have seen, you can use reportlab to rotate the canvas, apply the text, and then return to the original rotation. Here's an example.
# Be sure to import canvas from reportlab.
from reportlab.pdfgen import canvas
# When working with the PDF canvas, use the following.
can.drawString(10, 100, 'This text will be left to right')
can.saveState()
can.rotate(90)
can.drawString(10, 10, 'This text will be rotated 90 degrees')
can.restoreState()
can.save()
if you take a look at the various source codes in this and other forked repositories, you'll see that there are methods for rotating things. in the pdf file format, the concept of rotation works as follows: there is a rotate instruction that must wrap render instructions, followed by a "rotate back" instruction, so the code should probably look something like "doc.turn(); doc.write(); doc.turnback();" but this is an off the cuff answer just referencing what i know from last working on this project/pdf in general.
On Thu, Jun 28, 2018 at 5:33 PM, RHEV notifications@github.com wrote:
Yikes, I got a bit too far into my project to find this out.
Any solution would be extremely helpful!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/reingart/pyfpdf/issues/103#issuecomment-401180285, or mute the thread https://github.com/notifications/unsubscribe-auth/AIgjJJOYQsAGfupdNLRojdJbIAF-asGAks5uBUusgaJpZM4T9yOl .
https://github.com/alexanderankin/pyfpdf/blob/master/fpdf/fpdf.py#L766
On Thu, Jun 28, 2018 at 5:46 PM, David Ankin daveankin@gmail.com wrote:
if you take a look at the various source codes in this and other forked repositories, you'll see that there are methods for rotating things. in the pdf file format, the concept of rotation works as follows: there is a rotate instruction that must wrap render instructions, followed by a "rotate back" instruction, so the code should probably look something like "doc.turn(); doc.write(); doc.turnback();" but this is an off the cuff answer just referencing what i know from last working on this project/pdf in general.
On Thu, Jun 28, 2018 at 5:33 PM, RHEV notifications@github.com wrote:
Yikes, I got a bit too far into my project to find this out.
Any solution would be extremely helpful!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/reingart/pyfpdf/issues/103#issuecomment-401180285, or mute the thread https://github.com/notifications/unsubscribe-auth/AIgjJJOYQsAGfupdNLRojdJbIAF-asGAks5uBUusgaJpZM4T9yOl .
I asked the same question a couple of days ago on StackOverflow, but it seems that people there are not very familiar with PyFPDF or do not know a solution.
I'm currently generating a PDF with PyFPDF. I also need to add a vertical/rotated text. Unfortunately, it's not directly supported in PyPDF as far as I see. There are solutions for FPDF for PHP.
Is there a way to insert vertical or rotated text in a PDF from Python, either with PyFPDF or with another library?