Comments (1)
You can use stringBounds(String) on a PDFTTFFont object:
var font2 = new PDFTTFFont(pdf, new File("font.ttf").readAsBytesSync());
var s = "Hello World!";
var r = font2.stringBounds(s);
print(r);
// Draw a rect around the text
const FS = 20.0;
g.setColor(new PDFColor(0.0, 1.0, 1.0));
g.drawRect(50.0 + r.x * FS, 30.0 + r.y * FS, r.w * FS, r.h * FS);
g.fillPath();
g.setColor(new PDFColor(0.3, 0.3, 0.3));
g.drawString(font2, FS, s, 50.0, 30.0);
It works well with ttf fonts but not as good with PDFFont class (Helvetica, ...)
from dart_pdf.
Related Issues (20)
- Does not apply PdfColor in alpha HOT 1
- Pdf/A
- Restrictions on customizations
- The Urdu tag is for issues relating to displaying user interfaces and managing data in Udru written language
- When I press the shared button it calls onPrinted instead of onShared
- Extend NewPage with freeSpace HOT 3
- Callback for Print Success/Failure Notification HOT 3
- Not forwarding email extras when sharing
- Emoji's not displaying in PDF generated with dart_pdf HOT 2
- Send PDF to a wifi printer by ip
- Merging two pdf
- Merge two PDF's HOT 4
- Updating PDF page
- Russian text Rendering issue.
- Flutter printing: ^5.12.0 package is not working offline or when on local network
- Texts containing \n and \r sometimes don't work
- error build for flutter 3.22.0 (No named parameter with the name 'size'.) HOT 3
- Unable to build app on Flutter version 3.22.0 HOT 5
- Support `--wasm` flag in Flutter 3.22 for web HOT 2
- IntrinsicHeight widget
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 dart_pdf.