Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7851219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:06:50+00:00 2026-06-02T19:06:50+00:00

I’m currently working on an app that use ZXing to generate QR code as

  • 0

I’m currently working on an app that use ZXing to generate QR code as image. Here is a simple example:

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;

public class MyQREncoder {

    /**
     * @param args
     * @throws WriterException 
     * @throws IOException 
     * @throws FileNotFoundException 
     */
    public static void main(String[] args) throws WriterException, FileNotFoundException, IOException {
        String text = "Some text to encode";
        int width = 300;
        int height = 300;
        BitMatrix bitMatrix = new MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE,width,height);
        String file = "plop.png";
        String format = "png";
        MatrixToImageWriter.writeToStream(bitMatrix, format, new FileOutputStream(new File(file)));
    }

}

This generate a PNG file with a flashable QRcode saying “Some text to encode”.

My problem is, if I try to change format to eps, then I’d be given an empty file. The current solution we use is to convert the png file to eps through imagemagick convert utility. But the given EPS is just embedding the raw image, and do not scale well (especialy when printed).

Do someone know if there is any opensource solution (with Zxing or other) to build a scalable Eps file ? (or any vectorial format for instance)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:06:51+00:00Added an answer on June 2, 2026 at 7:06 pm

    Edit: Here’s a complete working solution in Java:

    PrintStream psFile = /* Open file */;
    
    final int blockSize = 4;
    
    psFile.println("%!PS-Adobe-3.0 EPSF-3.0");
    psFile.println("%%BoundingBox: 0 0 " + bitMatrix.getWidth() * blockSize + " " + bitMatrix.getHeight() * blockSize);
    
    psFile.print("/bits [");
    for(int y = 0; y < bitMatrix.getHeight(); ++y) {
        for(int x = 0; x < bitMatrix.getWidth(); ++x) {
            psFile.print(bitMatrix.get(x, y) ? "1 " : "0 ");
        }           
    }
    psFile.println("] def");
    
    psFile.println("/width " + bitMatrix.getWidth() + " def");
    psFile.println("/height " + bitMatrix.getHeight() + " def");
    
    psFile.println(
            "/y 0 def\n" + 
            blockSize + " " + blockSize + " scale\n" + 
            "height {\n" +
            "   /x 0 def\n" +
            "   width {\n" +
            "      bits y width mul x add get 1 eq {\n" +
            "         newpath\n" +
            "         x y moveto\n" +
            "         0 1 rlineto\n" +
            "         1 0 rlineto\n" +
            "         0 -1 rlineto\n" +
            "         closepath\n" +
            "         fill\n" +
            "      } if\n" +
            "      /x x 1 add def\n" +
            "   } repeat\n" +
            "   /y y 1 add def\n" +
            "} repeat\n");
    psFile.close();
    

    What about just generating the PS file yourself? Something like this:

    %!PS-Adobe-3.0 EPSF-3.0
    %%BoundingBox: 0 0 288 288
    
    /bits [0 0 1 0  1 0 1 1  0 1 1 0  1 1 0 0] def
    
    /width 4 def
    /height 4 def
    /y 0 def
    
    72 72 scale
    
    height {
       /x 0 def
       width {
          bits y width mul x add get 1 eq {
             newpath
             x y moveto
             0 1 rlineto
             1 0 rlineto
             0 -1 rlineto
             closepath
             fill
          } if
          /x x 1 add def
       } repeat
       /y y 1 add def
    } repeat
    

    (Where of course you would fill in the defs at the top with your own values, iterating through the BitMatrix and printing 1’s and 0’s to fill in bits)
    ps file output

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.