1

I am implementing pdf editing application by using itextpdf. I added a text into pdf and I am drawing a name on android system canvas by using canvas.drawPath() method.Like that I want to draw a names on pdfCanvas is it possible?.

I tried some of the example for drawing curves and rectangle on pdf canvas but is not giving exact solution.For drawing curves on pdf canvas I am using "PdfContentByte".In this class I found some of the methods

curveFromTo(x1,y1,x3,y3) curveTo(x2,y2,x3,y3) curveTo(x1,y1,x2,y2,x3,y3)

in this methods I am using curveFromTo() after saving it's giving mirror path not original path.

means if I draw PDF on android canvas its rotating like mirror image.

Is it possible to draw a path on PDF file.And is there any method like canvas.drawPAth();

user123456
  • 123
  • 1
  • 15

1 Answers1

1

First things first: there is no canvas.drawPath() method in iText.

Now for the rest of your question: there are methods to draw text on a PDF page using low-level functionality and methods to draw text using high-level functionality.

At the lowest level, one would use, a sequence of beginText(), setFontAndSize(), setTextMatrix(), showText() and endText() methods. This is called a "text object".

At a higher level, one could replace setTextMatrix() and showText() with a single showTextAligned() method.

At an even higher level, one could replace the complete sequence with a single ColumnText.showTextAligned() method.

At the highest level, on could create a ColumnText object, define a Rectangle for the column, add objects such as Paragraph, PdfPTable,... to the column and execute the go() method.

However: you are making a major mistake when you say:

after saving it's giving mirror path not original path.

means if I draw PDF on android canvas its rotating like mirror image.

Apart from the bad English, you are ignoring ISO-32000-1. By reading this ISO-standard, you'll discover that you are making wrong assumptions about the coordinate system in PDF. In a newly created PDF, the origin of the coordinate can be found in the lower-left corner. The X access extends to the right. The Y access extends upwards.

Android uses a different coordinate system. You need to make sure you transform coordinates when converting Android coordinates to PDF coordinates.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • Sorry for my bad english. Yes,Android using different coordinates.Android coordinates stating from upper left corner and pdf coordinates starting from lower left corner.So,How I can transfer android coordinates according to pdf coordinates and where I can transfer? – user123456 Jun 09 '14 at 08:35
  • Er... by using Math. It's only algebra, isn't it? – Bruno Lowagie Jun 09 '14 at 09:35
  • I don't understand the question. What are "touch coordinates"? – Bruno Lowagie Jun 12 '14 at 14:17
  • Thank you for giving replay.touch coordinates means x and y positions of pdf file.Finally I am getting exact touch coordinates of pdf file based on canvas touch with some math calculation. – user123456 Jun 13 '14 at 13:52