This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public File generate() throws IOException, WriterException { | |
| BitMatrix bitMatrix = createBitMatrix("https://medium.com/@thieunguyenhung", 100); | |
| File outputFileSVG = File.createTempFile("example", "qr.svg"); | |
| bitMatrixToSVG(bitMatrix, outputFileSVG); | |
| return outputFileSVG; | |
| } | |
| // ..... | |
| public class TestQrCodeGenerator { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.google.zxing.common.BitMatrix; | |
| import org.jfree.graphics2d.svg.SVGGraphics2D; | |
| import org.jfree.graphics2d.svg.SVGUtils; | |
| import java.awt.*; | |
| import java.io.File; | |
| import java.io.IOException; | |
| //..... | |
| private void bitMatrixToSVG(BitMatrix bitMatrix, File outputFileSVG) throws IOException { | |
| int matrixWidth = bitMatrix.getWidth(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.google.zxing.BarcodeFormat; | |
| import com.google.zxing.EncodeHintType; | |
| import com.google.zxing.WriterException; | |
| import com.google.zxing.common.BitMatrix; | |
| import com.google.zxing.qrcode.QRCodeWriter; | |
| import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| //....... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <dependencies> | |
| <!-- https://mvnrepository.com/artifact/com.google.zxing/core --> | |
| <dependency> | |
| <groupId>com.google.zxing</groupId> | |
| <artifactId>core</artifactId> | |
| <version>3.4.0</version> | |
| </dependency> | |
| <!-- https://mvnrepository.com/artifact/org.jfree/jfreesvg --> | |
| <dependency> |
Assume that we have a FormGroup called myForm and it hold another FormGroups called addresses (since one person can have more than one address). Each address have addressKind to determine its kind.
In the class code, it should be like this
public myForm: FormGroup;
constructor(private formBuilder: FormBuilder) {}
ngOnInit() {First we need to analyze the page source code. Fortunately, the page call a Javascript function inside a form to apply it, so we can run a Javascript script in Google Chrome Console in Developer mode to apply all the form in this page.
The steps are:
- Get all the forms in the page and parse them to Javascript array.
- Filter out the form that not match your need.
- Finally, loop through the array of forms to apply it.
var htmlForms = document.getElementsByTagName("form");
var tempForms = Array.from(htmlForms);NewerOlder
