Skip to content

Instantly share code, notes, and snippets.

@leoleozhu
leoleozhu / PdfGenerator.java
Created August 19, 2019 03:38
Draw transparent text with iText 7
class TextBox {
private UUID uuid;
private float x;
private float y;
private float width;
private float height;
@leoleozhu
leoleozhu / taopix-payment-icon.css
Created September 6, 2019 05:47
add payment icons for taopix checkout
div.paymentmethodlist>input[value="PAYPAL"] ~ label:after {
background-repeat: no-repeat;
background-image: url(/images/payments/paypal-640x188.png);
background-size: 48px 14px;
display: inline-block;
width: 48px;
height: 14px;
content: "";
margin-left: 20px;
@leoleozhu
leoleozhu / GuessContentTypeTest.java
Created October 30, 2019 02:38
guess image content type from URL
public class GuessContentTypeTest extends TestCase {
@Test
public void testGuessFileTypeFromUrl() throws Exception {
String[] urls = {
// your image urls here
};
for(String s : urls) {
int pushbackLimit = 100;
@leoleozhu
leoleozhu / ReusePage.java
Created August 5, 2021 10:49
Reuse page in PDF
@Test
public void testReusePage() throws Exception {
String original = resourceFile("PdfWithImage.pdf");
String destination = targetFile("image-reuse-ReusePage.pdf");
try (
PdfDocument input = new PdfDocument(new PdfReader(original));
PdfDocument output = new PdfDocument(new PdfWriter(destination))
) {
PdfPage page = input.getPage(1);
@leoleozhu
leoleozhu / setjdk.bat
Created December 9, 2021 07:36 — forked from torutk/setjdk.bat
Setting oracle jdk path using registory for Windows command prompt
@echo off
:: ==========================================================
:: Windows(64bit) batch file tor set environment variables
:: JAVA_HOME and PATH for Oracle JDK or OpenJDK.
::
:: For Oracle JDK, search JDK installed path from Windows registory.
:: For OpenJDK, search JDK installed path from directory name under
:: OPENJDK_BASE directory specified in this batch file. (needs to
:: customize your configuration)
@leoleozhu
leoleozhu / DownloadUtils.java
Last active January 11, 2022 10:57
Download file with HTTP resumable
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.apache.commons.io.IOUtils;
import java.io.*;
import java.net.URL;