2014-02-05 2 views

ответ

1

пожалуйста, смотрите в этот пример ...

public static void Main() { 


     // step 1: creation of a document-object 
     Document document = new Document(); 


     try { 


      // step 2: 
      // we create a writer that listens to the document 
      // and directs a PDF-stream to a file 
      PdfWriter writer = PdfWriter.getInstance(document, new FileStream("Chap1002.pdf", FileMode.Create)); 


      // step 3: we open the document 
      document.Open(); 


      // step 4: we grab the ContentByte and do some stuff with it 
      PdfContentByte cb = writer.DirectContent; 


      // we tell the ContentByte we're ready to draw text 
      cb.beginText(); 


      // we draw some text on a certain position 
      cb.setTextMatrix(100, 400); 
      cb.showText("Text at position 100,400."); 


      // we tell the contentByte, we've finished drawing text 
      cb.endText(); 
     } 
     catch(DocumentException de) { 
      Console.Error.WriteLine(de.Message); 
     } 
     catch(IOException ioe) { 
      Console.Error.WriteLine(ioe.Message); 
     } 


     // step 5: we close the document 
     document.Close(); 
    } 
} 
+1

Это не отвечает на вопрос, не так ли? Добавление таблицы в абсолютном положении выполняется с помощью метода WriteSelectedRows() 'или путем обертывания таблицы в объект' ColumnText'. –

0

Пожалуйста, обратите внимание на # порт C примеров главы 4 my book: http://tinyurl.com/itextsharpIIA2C04

Вы можете добавить таблицу к объекту ColumnText и добавить колонку в абсолютное положение:

ColumnText column = new ColumnText(writer.DirectContent); 
column.AddElement(table); 
column.SetSimpleColumn(llx, lly, urx, ury); 
column.Go(); 

В этом фрагменте llx, lly и urx, yury находятся координаты нижнего левого угла и верхний правый угол столбца на странице (см. Пример ColumnTable).

В PdfCalendar примере используется другой метод:

table.WriteSelectedRows(0, -1, x, y, writer.DirectContent); 

Первые параметры определяют, которые должны быть сделаны строки (от 0 до -1 означает все строки), x и y определяют абсолютное положение ,

Смежные вопросы