Bild auto passt in PdfPCell mit iTextSharp

Ich habe ein seltsames problem mit Bildern in der iTextSharp-Bibliothek.
Ich bin hinzufügen, das Bild auf die PdfPCell und für einige Grund wird es skaliert.
Wie halte ich es auf Originalgröße?

Ich aber, dass die Bilder gleichen, wenn es gedruckt wird aber der Unterschied auf dem Bild ist das gleiche auf die gedruckte version. Manuell skalieren Sie das Bild mit ScaleXXX, um es zu Recht scheint mir ein bisschen unlogisch und nicht geben, ein gutes Ergebnis.

So, wie ich das Bild in seiner ursprünglichen Größe innerhalb einer PdfPCell einer Tabelle, ohne zu skalieren?

Hier ist mein code:

private PdfPTable CreateTestPDF()
{
    PdfPTable table = new PdfPTable(1);
    table.WidthPercentage = 100;

    Phrase phrase = new Phrase("MY TITLE", _font24Bold);
    table.AddCell(phrase);

    PdfPTable nestedTable = new PdfPTable(5);
    table.WidthPercentage = 100;

    Phrase cellText = new Phrase("cell 1", _font9BoldBlack);
    nestedTable.AddCell(cellText);

    cellText = new Phrase("cell 2", _font9BoldBlack);
    nestedTable.AddCell(cellText);

    cellText = new Phrase("cell 3", _font9BoldBlack);
    nestedTable.AddCell(cellText);

    iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(@"d:\MyPic.jpg");
    image.Alignment = iTextSharp.text.Image.ALIGN_CENTER;
    PdfPCell cell = new PdfPCell(image);
    cell.HorizontalAlignment = PdfPCell.ALIGN_MIDDLE;
    nestedTable.AddCell(cell);

    cellText = new Phrase("cell 5", _font9BoldBlack);
    nestedTable.AddCell(cellText);

    nestedTable.AddCell("");

    string articleInfo = "Test Text";
    cellText = new Phrase(articleInfo, _font8Black);
    nestedTable.AddCell(cellText);

    nestedTable.AddCell("");
    nestedTable.AddCell("");
    nestedTable.AddCell("");

    table.AddCell(nestedTable);
    SetBorderSizeForAllCells(table, iTextSharp.text.Rectangle.NO_BORDER);
    return table;
}

static BaseColor _textColor = new BaseColor(154, 154, 154);
iTextSharp.text.Font _font8 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, iTextSharp.text.Font.NORMAL, _textColor);
iTextSharp.text.Font _font8Black = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
iTextSharp.text.Font _font9 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 9, iTextSharp.text.Font.NORMAL, _textColor);
iTextSharp.text.Font _font9BoldBlack = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 9, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
iTextSharp.text.Font _font10 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.NORMAL, _textColor);
iTextSharp.text.Font _font10Black = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
iTextSharp.text.Font _font10BoldBlack = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
iTextSharp.text.Font _font24Bold = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 24, iTextSharp.text.Font.BOLD, _textColor);
  • Welche version von iTextSharp verwenden Sie?
  • ich bin mit iTextSharp 5.0.2.0
  • Es ist wie 4 Uhr in Slowenien. Haben Sie jemals schlafen? 🙂
  • tatsächlich ist es schon 5 Uhr. Es ist eine jener Nächte, in denen ich tief Tauchen Sie ein in etwas, vergessen Sie die Zeit und überspringen Sie einfach die Nacht 🙂
  • Sie können fix die Bilder?
Schreibe einen Kommentar