-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8e34c14
Showing
35 changed files
with
779 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.DS_Store | ||
*/target/** | ||
|
||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff: | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/dictionaries | ||
|
||
# Sensitive or high-churn files: | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.xml | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
|
||
# Gradle: | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# CMake | ||
cmake-build-debug/ | ||
|
||
# Mongo Explorer plugin: | ||
.idea/**/mongoSettings.xml | ||
|
||
## File-based project format: | ||
*.iws | ||
|
||
## Plugin-specific files: | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Shipping Labeler | ||
|
||
This is a simple Java App to convert PDF Files for a 62mm Labelprinter. Currently only a few German carriers are implemented. To change this, Pull-Requests are always welcome :) | ||
|
||
|
||
## Usage | ||
|
||
Java 8 is required. | ||
|
||
Just download the latest release and execute the jar file with the terminal(macOS)/shell(Linux)/cmd(Windows) or whatever :) | ||
|
||
Command: | ||
`java -jar shippinglabeler.jar` | ||
|
||
(Don't worry. A GUI is planned :D ) | ||
|
||
Now you can insert the path of your PDF label and select the carrier of it. After this the converted document will be shown in your default PDF-Viewer. | ||
|
||
Please print the document on a 62 x 184 (sometimes 62 x 209 ) label. Otherwise you risk that the barcodes on the labels aren't readable. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>de.flecktec</groupId> | ||
<artifactId>shippinglabeler</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.6.2</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>de.flecktec.shippinglabeler.PDFMain</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>make-assembly</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.pdfbox</groupId> | ||
<artifactId>pdfbox</artifactId> | ||
<version>2.0.4</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Maven: org.apache.pdfbox:pdfbox:2.0.4" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.pdfbox:fontbox:2.0.4" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" /> | ||
</component> | ||
</module> |
52 changes: 52 additions & 0 deletions
52
src/main/java/de/flecktec/shippinglabeler/AmazonRetourLabelCreator.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package de.flecktec.shippinglabeler; | ||
|
||
import org.apache.pdfbox.pdmodel.PDDocument; | ||
import org.apache.pdfbox.pdmodel.PDPage; | ||
import org.apache.pdfbox.pdmodel.PDPageContentStream; | ||
import org.apache.pdfbox.pdmodel.common.PDRectangle; | ||
import org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory; | ||
|
||
import javax.imageio.ImageIO; | ||
import java.awt.*; | ||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Created by jonas on 01.09.17. | ||
*/ | ||
public class AmazonRetourLabelCreator extends LabelCreator { | ||
|
||
@Override | ||
public void createPDF(File path, File source) { | ||
try ( final PDDocument targetdocument = new PDDocument()) { | ||
BufferedImage img = ImageIO.read(source); | ||
img = rotateImage(img, 90); | ||
final PDPage singlePage = new PDPage(new PDRectangle(177f * mm, 56f * mm)); | ||
targetdocument.addPage(singlePage); | ||
final PDPageContentStream contentStream = new PDPageContentStream(targetdocument, singlePage); | ||
|
||
BufferedImage senderLabel = cropImage(img, new Rectangle(mmToPixels(12) , mmToPixels(6), mmToPixels(50) ,mmToPixels(22))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, senderLabel), 0*mm, 34*mm, 50*mm, 22 * mm); | ||
|
||
BufferedImage receiverLabel = cropImage(img, new Rectangle(mmToPixels(6) , mmToPixels(60), mmToPixels(50) ,mmToPixels(28))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, receiverLabel), 0*mm, 0*mm, 50*mm, 28 * mm); | ||
|
||
BufferedImage packetNumberLabel = cropImage(img, new Rectangle(mmToPixels(26) , mmToPixels(38), mmToPixels(46), mmToPixels(20))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, packetNumberLabel), 52*mm, 30*mm, 60*mm, 26 * mm); | ||
|
||
BufferedImage routingCodeLabel = cropImage(img, new Rectangle(mmToPixels(3) , mmToPixels(105), mmToPixels(53) ,mmToPixels(20))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, routingCodeLabel), 113*mm, 30*mm, 69*mm, 26 * mm); | ||
|
||
BufferedImage rmaCodeLabel = cropImage(img, new Rectangle(mmToPixels(15) , mmToPixels(127), mmToPixels(72) ,mmToPixels(19))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, rmaCodeLabel), 62*mm, 0*mm, 93*mm, 25 * mm); | ||
|
||
|
||
contentStream.close(); | ||
targetdocument.save(path); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/de/flecktec/shippinglabeler/Controller/MainViewController.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package de.flecktec.shippinglabeler.Controller; | ||
|
||
/** | ||
* Created by jonas on 04.10.17. | ||
*/ | ||
public class MainViewController { | ||
} |
85 changes: 85 additions & 0 deletions
85
src/main/java/de/flecktec/shippinglabeler/DHLLabelCreator.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package de.flecktec.shippinglabeler; | ||
|
||
import org.apache.pdfbox.pdmodel.PDDocument; | ||
import org.apache.pdfbox.pdmodel.PDPage; | ||
import org.apache.pdfbox.pdmodel.PDPageContentStream; | ||
import org.apache.pdfbox.pdmodel.PDPageTree; | ||
import org.apache.pdfbox.pdmodel.common.PDRectangle; | ||
import org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory; | ||
import org.apache.pdfbox.rendering.ImageType; | ||
import org.apache.pdfbox.rendering.PDFRenderer; | ||
|
||
import java.awt.*; | ||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Created by jonas on 13.08.17. | ||
*/ | ||
public class DHLLabelCreator extends LabelCreator { | ||
|
||
public void createPDF(File path, File source) { | ||
System.out.println("Creating PDF"); | ||
try (PDDocument sourceDocument = PDDocument.load(source); final PDDocument targetdocument = new PDDocument()) | ||
{ | ||
PDFRenderer pdfRenderer = new PDFRenderer(sourceDocument); | ||
for (int page = 0; page < sourceDocument.getNumberOfPages(); ++page) | ||
{ | ||
System.out.println("Rendering page "+ page); | ||
sourceDocument.getPage(page).setRotation(90); | ||
BufferedImage bim = pdfRenderer.renderImageWithDPI(page, dpi, ImageType.RGB); | ||
System.out.println(bim.getWidth()); | ||
System.out.println(mmToPixels(297)); | ||
System.out.println("Creating new page"); | ||
final PDPage singlePage = new PDPage(new PDRectangle(177f * mm, 56f * mm)); | ||
targetdocument.addPage(singlePage); | ||
final PDPageContentStream contentStream = new PDPageContentStream(targetdocument, singlePage); | ||
/*BufferedImage adressLabel = cropImage(bim, new Rectangle(mmToPixels(160) , mmToPixels(16), mmToPixels(106) ,mmToPixels(53))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, adressLabel), 0*mm, 0*mm, 113*mm, 56.08f * mm); | ||
BufferedImage barcode1 = cropImage(bim, new Rectangle(mmToPixels(185) , mmToPixels(131), mmToPixels(55) ,mmToPixels(25))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, barcode1), 116*mm, 28*mm, 55*mm, 25 * mm); | ||
BufferedImage barcode2 = cropImage(bim, new Rectangle(mmToPixels(185) , mmToPixels(164), mmToPixels(55) ,mmToPixels(25))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, barcode2), 116*mm, 0*mm, 55*mm, 25 * mm);*/ | ||
|
||
BufferedImage adressLabel = cropImage(bim, new Rectangle(mmToPixels(160) , mmToPixels(16), mmToPixels(106) ,mmToPixels(53))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, adressLabel), 0*mm, 0*mm, 113*mm, 56.08f * mm); | ||
|
||
BufferedImage barcode1 = cropImage(bim, new Rectangle(mmToPixels(185) , mmToPixels(131), mmToPixels(55) ,mmToPixels(25))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, barcode1), 116*mm, 30*mm, 55*mm, 25 * mm); | ||
|
||
BufferedImage barcode2 = cropImage(bim, new Rectangle(mmToPixels(185) , mmToPixels(164), mmToPixels(55) ,mmToPixels(25))); | ||
contentStream.drawImage(JPEGFactory.createFromImage(targetdocument, barcode2), 116*mm, 0*mm, 55*mm, 25 * mm); | ||
|
||
contentStream.close(); | ||
|
||
|
||
} | ||
|
||
targetdocument.save(path); | ||
/*for(Smarthomeitem item : smarthomeitems) { | ||
final PDPage singlePage = new PDPage(new PDRectangle(62 * mm, 25 * mm)); | ||
document.addPage(singlePage); | ||
final PDPageContentStream contentStream = new PDPageContentStream(document, singlePage); | ||
String json = new Gson().toJson(item); | ||
BufferedImage qr = createQRImage(json, 250); | ||
contentStream.drawImage(JPEGFactory.createFromImage(document, qr), 2*mm, 3*mm, 19*mm, 19 * mm); | ||
contentStream.beginText(); | ||
contentStream.setFont(PDType1Font.COURIER_BOLD, 8); | ||
contentStream.newLineAtOffset(22* mm, 14* mm); | ||
contentStream.showText(item.getName()); | ||
contentStream.endText(); | ||
contentStream.close(); | ||
} | ||
document.save(path); | ||
System.out.println("Finished"); */ | ||
|
||
} | ||
catch (IOException ioEx) | ||
{ | ||
ioEx.printStackTrace(); | ||
} | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.