क्या iTextSharp में एक तालिका (पीडीएफपीटेबल) के भीतर सेल स्पेसिंग होना संभव है? मैं कहीं भी नहीं देख सकता कि यह संभव है। मैंने iTextSharp.text.Table का उपयोग करने का एक सुझाव देखा था, लेकिन यह iTextSharp (5.2.1) के मेरे संस्करण पर उपलब्ध नहीं प्रतीत होता है।iTextSharp टेबल सेल स्पेसिंग संभव है?
6
A
उत्तर
1
तालिका वर्ग को पीडीएफपीटेबल के पक्ष में 5.x से शुरू होने वाले आईटेक्स्ट से हटा दिया गया है।
अंतर के लिए, आप जो खोज रहे हैं वह सेटपैडिंग विधियां हैं। आप देख रहे हैं
http://api.itextpdf.com/itext/com/itextpdf/text/pdf/PdfPCell.html
(यह जावा संस्करण के लिए है, लेकिन सी # बंदरगाह तरीकों के नाम बनाए रखता है)
13
:
अधिक जानकारी के लिए iText के एपीआई पर एक नज़र डालें एचटीएमएल की तरह सही सेल स्पेसिंग के लिए, PdfPTable
उस मूल रूप से समर्थन नहीं करता है। हालांकि, PdfPCell
ऐसी संपत्ति का समर्थन करता है जो IPdfPCellEvent
का कस्टम कार्यान्वयन करता है जिसे सेल लेआउट होने पर कॉल किया जाएगा। नीचे एक का एक सरल कार्यान्वयन है, आप शायद इसे अपनी जरूरतों के अनुसार बदलना चाहते हैं।
public class CellSpacingEvent : IPdfPCellEvent {
private int cellSpacing;
public CellSpacingEvent(int cellSpacing) {
this.cellSpacing = cellSpacing;
}
void IPdfPCellEvent.CellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
//Grab the line canvas for drawing lines on
PdfContentByte cb = canvases[PdfPTable.LINECANVAS];
//Create a new rectangle using our previously supplied spacing
cb.Rectangle(
position.Left + this.cellSpacing,
position.Bottom + this.cellSpacing,
(position.Right - this.cellSpacing) - (position.Left + this.cellSpacing),
(position.Top - this.cellSpacing) - (position.Bottom + this.cellSpacing)
);
//Set a color
cb.SetColorStroke(BaseColor.RED);
//Draw the rectangle
cb.Stroke();
}
}
इसका इस्तेमाल करने के लिए:
//Create a two column table
PdfPTable table = new PdfPTable(2);
//Don't let the system draw the border, we'll do that
table.DefaultCell.Border = 0;
//Bind our custom event to the default cell
table.DefaultCell.CellEvent = new CellSpacingEvent(2);
//We're not changing actual layout so we're going to cheat and padd the cells a little
table.DefaultCell.Padding = 4;
//Add some cells
table.AddCell("Test");
table.AddCell("Test");
table.AddCell("Test");
table.AddCell("Test");
doc.Add(table);
-4
प्रयास करें यह
PdfPTable table = new PdfPTable(2);
table.getDefaultCell().setBorder(0);
table.getDefaultCell().setPadding(8);
table.addCell("Employee ID");
table.addCell("");
table.addCell("Employee Name");
table.addCell("");
table.addCell("Department");
table.addCell("");
table.addCell("Place");
table.addCell("");
table.addCell("Contact Number");
table.addCell("");
document.add(table);
संबंधित मुद्दे
- 1. iTextSharp वर्टिकल स्पेसिंग
- 2. सफारी 5.1 ब्रेक सीएसएस टेबल सेल स्पेसिंग
- 3. ITextSharp: सेट टेबल सेल सीमा रंग
- 4. जीमेल ईमेल टेबल स्पेसिंग
- 5. iTextSharp
- 6. टेबल सेल
- 7. टेबल सेल
- 8. "लालची" टेबल सेल बनाएं?
- 9. जावाएफएक्स टेबल सेल स्वरूपण
- 10. Itextsharp
- 11. आईफ़ोन टेबल सेल लेबल misaligned
- 12. टेबल सेल में केंद्र टेक्स्ट
- 13. ऑर्ग-मोड टेबल सेल फ़ॉन्टिफिकेशन
- 14. आईओएस टेबल व्यू रीफ्रेश सेल
- 15. iTExtsharp
- 16. iTextSharp - क्या एक ही सेल और पंक्ति के लिए एक अलग फ़ॉन्ट रंग सेट करना संभव है?
- 17. iTextSharp
- 18. एक एचटीएमएल टेबल सेल में सेलपैडिंग
- 19. iTextSharp
- 20. ओपन एक्सएमएल पैराग्राफ स्पेसिंग
- 21. ITextSharp
- 22. iTextSharp
- 23. itextsharp pdf निर्माण में सेल चौड़ाई कैसे सेट करें
- 24. क्या डिस्प्ले के लिए कोई पॉलीफिल है: टेबल, टेबल-पंक्ति, टेबल-सेल इत्यादि
- 25. itextsharp
- 26. iTextSharp
- 27. iTextSharp
- 28. iTextSharp
- 29. itextsharp
- 30. iTextSharp
कि के लिए धन्यवाद, लेकिन वह (कोशिका के भीतर) सेल गद्दी को जोड़ने के लिए है। मुझे सेल स्पेसिंग (कोशिकाओं के बीच) की आवश्यकता है। –