Comments (2)
@nico75005 It worked perfectly ... 👍 Thank you so much!!!
from simplepdf.
It's not used at all. You can replace the content of the method line 302 in SimplePDF.swift
fileprivate func drawTable(rowCount: Int, alignment: ContentAlignment, columnCount: Int, rowHeight: CGFloat, columnWidth: CGFloat?, tableLineWidth: CGFloat, font: UIFont?, tableDefinition:TableDefinition?, dataArray: Array<Array<String>>, currentOffset: CGPoint) -> CGRect
with this:
fileprivate func drawTable(rowCount: Int, alignment: ContentAlignment, columnCount: Int, rowHeight: CGFloat, columnWidth: CGFloat?, tableLineWidth: CGFloat, font: UIFont?, tableDefinition:TableDefinition?, dataArray: Array<Array<String>>, currentOffset: CGPoint) -> CGRect {
let height = (CGFloat(rowCount)*rowHeight)
let drawRect = CGRect(x: currentOffset.x, y: currentOffset.y, width: pageBounds.width - pageMarginLeft - pageMarginRight, height: height)
UIColor.black.setStroke()
UIColor.black.setFill()
let tableWidth = { () -> CGFloat in
if let cws = tableDefinition?.columnWidths {
return cws.reduce(0, { (result, current) -> CGFloat in
return result + current
})
} else if let cw = columnWidth {
return CGFloat(columnCount) * cw
}
return 0 // default which should never be use, because either columnWidth, or columnsWidths is set
}()
for i in 0...rowCount {
let newOrigin = drawRect.origin.y + rowHeight*CGFloat(i)
let from = CGPoint(x: drawRect.origin.x, y: newOrigin)
let to = CGPoint(x: drawRect.origin.x + tableWidth, y: newOrigin)
drawLineFromPoint(from, to: to, lineWidth: tableLineWidth)
}
for i in 0...columnCount {
let currentOffset = { () -> CGFloat in
if let cws = tableDefinition?.columnWidths {
var offset:CGFloat = 0
for x in 0..<i {
offset += cws[x]
}
return offset
} else if let cw = columnWidth {
return cw * CGFloat(i)
}
return 0 // default which should never be use, because either columnWidth, or columnsWidths is set
}()
let newOrigin = drawRect.origin.x + currentOffset
let from = CGPoint(x: newOrigin, y: drawRect.origin.y)
let to = CGPoint(x: newOrigin, y: drawRect.origin.y + CGFloat(rowCount)*rowHeight)
drawLineFromPoint(from, to: to, lineWidth: tableLineWidth)
}
for i in 0..<rowCount {
for j in 0...columnCount-1 {
let currentOffset = { () -> CGFloat in
if let cws = tableDefinition?.columnWidths {
var offset:CGFloat = 0
for x in 0..<j {
offset += cws[x]
}
return offset
} else if let cw = columnWidth {
return cw * CGFloat(j)
}
return 0 // default which should never be use, because either columnWidth, or columnsWidths is set
}()
let newOriginX = drawRect.origin.x + currentOffset
let newOriginY = drawRect.origin.y + ((CGFloat(i)*rowHeight))
let currentAlignment = { () -> ContentAlignment in
if let a = tableDefinition?.alignments {
if (a.count > j){
return a[j]
}
} else {
return alignment
}
return .left
}()
let currentFont = { () -> UIFont in
if let f = tableDefinition?.fonts {
if (f.count > j){
return f[j]
}
} else if let f = font {
return f
}
return UIFont.systemFont(ofSize: UIFont.systemFontSize)
}()
let currentTextColor = { () -> UIColor in
if let t = tableDefinition?.textColors {
if t.count > j {
return t[j]
}
}
return UIColor.black
}()
let currentColumnWidth = { () -> CGFloat in
if let cw = tableDefinition?.columnWidths {
if cw.count > j {
return cw[j]
}
} else if let cw = columnWidth {
return cw
}
return 100 // default which should never be use, because either columnWidth, or columnsWidths is set
}()
let frame = CGRect(x: newOriginX, y: newOriginY, width: currentColumnWidth, height: rowHeight)
drawTextInCell(frame, text: dataArray[i][j] as NSString, alignment: currentAlignment, font: currentFont, textColor: currentTextColor)
}
}
return drawRect
}
from simplepdf.
Related Issues (20)
- Cell Background Color HOT 1
- Issue with compile errors HOT 6
- Add contents of a UITableView? HOT 3
- How to use this code? HOT 1
- How to add multiple pages? HOT 12
- Strike through Style and NSTextAttachment support
- Objective-C version available ?
- URL Error
- Table alignment is not working.
- How to add multiple images in a single row?
- Support for macOS HOT 1
- Any way to change font SIZE? HOT 1
- CMYK support
- Any way to change image size ?
- How to begin new page automatically HOT 2
- How to add custom name for pdf file?
- How to add a digital signature field HOT 1
- PDF page background
- Architecture error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplepdf.