Certain barcodes break pdf stream when viewed in certain mobile mail clients

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for Java (v7)  /  Certain barcodes break pdf stream when viewed in certain mobile mail clients

DynamicPDF Merger for Java (v7) Forum

Hi people!

We have a Java application that sends pdf etickets to customers. These consist of pdf files made in Illustrator and supplied with TextFields in Acrobat. Then our Java application, using the CeTe lib 7, puts content in these fields and creates a number of barcode fields (all with the same barcode value).

We got complaints that some of these eTickets were empty when opened on iPhones. After pulling at least half of my hair out, we pinned the problem down to what seems to be a problem with the barcode fields. I am now able to reproduce quite exactly on all iPhones present in our company.

In short: certain barcode numbers always break stuff, while certain others never do. In the broken scenario, what happens is the first barcode that is created is visible when opened in iPhone's (3/4/5) Preview application, but the numbers below it are not visible and any field created or altered after that barcode is also not visible. When the PDF is opened in Acrobat Reader (even on the iPhones themselves), everything looks fine.


I wrote a small Java reproducer. I cannot add attachment on this forum ( :-/ ) so I'll just put it in here:

--------------------
package nl.seetickets.eticket;

import java.io.*;

import com.cete.dynamicpdf.Document;
import com.cete.dynamicpdf.Page;
import com.cete.dynamicpdf.merger.MergeDocument;
import com.cete.dynamicpdf.merger.PdfDocument;
import com.cete.dynamicpdf.pageelements.Label;
import com.cete.dynamicpdf.pageelements.barcoding.Interleaved25;

public class SaveHardcodedPdf {

        private static final String PDF_TEMPLATE = "c:\\tmp\\reprod_formats\\emptydoc.pdf";
        private static final String TEMP_DIR = "d:\\dev\\workspace\\eTicket-lib-trunk\\tmp\\";
        
        public static void main(String[] arguments) throws Exception {

                String brokenValue = "29292207233636";
                String workingValue  = "29296236330622";

                createPdf(brokenValue, "broken.pdf");
                createPdf(workingValue, "working.pdf");
        }

        private static void createPdf(String barCodeValue, String filename)
            throws FileNotFoundException, IOException {
           
                File templateFile = new File(PDF_TEMPLATE);

        FileInputStream input = new FileInputStream(templateFile);

                PdfDocument pdfDocument = new PdfDocument(input);

                final Document mergeDocument = new MergeDocument(pdfDocument);
                
                Page firstPage = mergeDocument.getPages().getPage(0);
                
                firstPage.getElements().add(new Interleaved25(barCodeValue, 8f, 80f, 41f, 1f, true));
                firstPage.getElements().add(new Label("This is a label", 8f, 160f, 80f, 5f));
                
                File outputFile = new File(TEMP_DIR + filename);
                
            OutputStream output = new FileOutputStream(outputFile);
            mergeDocument.draw(output);
            output.flush();
            output.close();
           
            System.out.print("Created file: " + outputFile.getAbsolutePath());
    }
}
--------------------

What you need for reproducing is:
-        Acrobat: File -> Create PDF -> From Blank Page -> Save as "your.pdf" (so, a very clean empty pdf file)
-        Edit the paths in the java reproducer for your environment
-        run it, and mail the documents to some box you can open on an iPhone. The resulting "working.pdf" should have a barcode with some numbers below, and a Label below that. The "broken.pdf" should have just the barcode, no numbers and no label.

What I already tried, but did not make any difference:
- using different barcode types (Code128 etc.)
- setting all sorts of security/resizing/formatting/rotating properties to the document
- using size reducers in Acrobat and setting PDF versions in the created pdf document

I really hope anyone has any idea where this problem lies, or better yet ofcourse how to fix it.
Posted by a ceTe Software moderator
Hello,

We are doing some testing on our end to figure out what the issue is. We will post an update as soon as we are done with our testing. 

Thanks,
ceTe Software Support Team.
Posted by a ceTe Software moderator
Hello,

Our developers analyzed the two PDF documents you sent and both are valid PDF documents. The internal structure indicates that the content is definitely present in content stream of both PDFs, however the iPhone’s Preview is unable to render the PDF content correctly. We have tested these documents on several other PDF Viewers including the Adobe Reader on iPhone and PDFs are displayed correctly. Our component is generating the PDFs correctly and this is a rendering issue with iPhone’s Preview.
Thanks,
ceTe Software Support Team.
Thanks for researching!

I think it’s interesting that we are seemingly the first customer ever to complain about weird handling of some barcodes on Apple Preview. Especially since it’s very unlikely that we are the first ones to run into this issue, if only because we’ve had complaints about this for quite some time.

Hopefully we will get somewhere when we ask Apple support.

Regards,
Bouke Bergsma
See Tickets

All times are US Eastern Standard time. The time now is 8:13 PM.