yan74 / afplib

JAVA Library for reading & writing AFP (Advanced Function Presentation) Files.
Apache License 2.0
37 stars 22 forks source link

Not issue - PTX example #8

Closed bta01 closed 7 years ago

bta01 commented 7 years ago

Hi Yan, first of all congratulations for that library.

I am facing some issues to write an simple "hello world" using the PTX interface. Could you please share a class showing how to do that?

Thank you

yan74 commented 7 years ago

Hi @bta01,

please have a look at #3 - maybe this answers your question.

y

mbefokam commented 7 years ago

Hi @yan74 , Thank you for this amazing library. I am trying to use it for my project. I read the MO:DCA documentation and now i am trying to convert a PDF to APF. I am using the issue #3 as my base code. But on of itself I have some problem. Here is my issue:

on this source code, you are passing a simple string "Hello World" on line

byte[] text = new String("Hello World").getBytes(Charset.forName("IBM500"));

I am trying to parse a pdf to byte array using two approaches they both don t work. My PDF has text only. 1- the first approach is to I am using PdfReader. PdfReader = reader = new PdfReader("mypdf");

byte[] text = reader.getPageContent(1); but with this approach your library is not able to read my bytes and my get an ArraysOut of bound exception.

2 approach I read the PDF as an input stream.

InputStream pdffile = Buff....("mypdf")

then I used the pattern that you used in the case of pdf to overlay to right every bytes at the time.

byte[] buffer = new byte[MAX_SIZE] int l while ((l = pdffile.read(buffer)) >0) PTX ptx = Afp..... byte [] c = new byte[l] System.arraycopy(buffer, o, c, 0, l) aout.writeS(ptx)

This approach create a legit afp file but the file is empty. Event when I used apache.commons.io.IOUtils to convert my input stream to byte arrays it still does not work.

The only side option that works a half way it to convert the pdf to string first then string to array bytes. But in this case you lose the format and the string is written as a single line on the file.

Finally it will be helpful for people like my passionate about afp and following pretty closely your great work if you could have a pdf to afp clear example. The pdf should have like let say 2 pages, and should be a mixed of text, graph picture and bar code.

Thank you for your time.

bta01 commented 7 years ago

Thank vou Yan, You really help me a lot.