I'm having to save the file to the server, which is unfortunate. I'll have to come up with a naming scheme and a way to clean up the files but things appear to be working out well. Here's the PHP code I'm using:

$pdf_encoded = $response['pkgs']['0']['label_img'];
file_put_contents('test_tracking.pdf',base64_decode($pdf_encoded));
$tracking = $response['pkgs']['0']['pkg_trk_num'];
echo '<a href="./test_tracking.pdf" >Click here for your mailing label!</a><br />';
echo 'Your tracking number: ' . $tracking . '<br />';

Hope this helps someone out.
-Kevin


On 10/22/2013 11:12 PM, Virgil Bierschwale wrote:
I'm going to call it a night, but first here is a link to the spec (I think
as I haven't seen your examples)

https://ribbs.usps.gov/onecode_solution/documents/tech_guides/SPUSPS-B-3200E
001.pdf

On page 55 through 57, it looks like you can brute force decode it depending
on whether they are descending, or ascending characters.

For example, if position one is going down, it is a "H"
If it is going up, it is a "E"

More than I wanted to know this late at night, but if you do figure it out,
I would be interested in learning more along these lines as I'm trying to
add a online store to K.A.A.W and a few other things which is why I want to
understand it.

Thanks,

Virgil



-----Original Message-----
From: ProFox [mailto:profox-boun...@leafe.com] On Behalf Of Kevin Cully
Sent: Tuesday, October 22, 2013 9:51 PM
To: profox@leafe.com
Subject: Re: [NF] Display PDF from USPS response

I guess that's the rub.  The pdf isn't on their server.  They're responding
with the PDF encoded in their response as encoded 64bit string.  To provide
a traditional link to the PDF, I would need to save the PDF onto our server.
Don't want to do that for a whole variety of reasons.

What I'd like to do is to trigger the download, or somehow embed it in a
page using the <embed> tag or an <iframe>?  Not ideal.  I wish they provided
the PDF on their server.  Ah well. Help?


On 10/22/2013 10:36 PM, Virgil Bierschwale wrote:
Reason I asked is I was wondering if that needed to be printed on the
label.
If not, and they return a link to the pdf that remains on the usps
server, couldn't you pass that?

I'm curious because I'm looking at something along those lines down
the road and you're the first one I've heard mention it

-----Original Message-----
From: ProFox [mailto:profox-boun...@leafe.com] On Behalf Of Kevin
Cully
Sent: Tuesday, October 22, 2013 9:35 PM
To: profox@leafe.com
Subject: Re: [NF] Display PDF from USPS response

Hello Virgil,

The question really isn't about creating a mailing label with a barcode.
Basically my client pays for the return shipping by paying for the
postage and providing them the return mailing label ... all via the
browser.
Thanks for the thought though.
-Kevin

On 10/22/2013 10:31 PM, Virgil Bierschwale wrote:
Have you seen this?

https://www.usps.com/election-mail/creating-imb-election-mail-kit.pdf


-----Original Message-----
From: ProFox [mailto:profox-boun...@leafe.com] On Behalf Of Kevin
Cully
Sent: Tuesday, October 22, 2013 9:28 PM
To: profoxt...@leafe.com
Subject: [NF] Display PDF from USPS response

I'm working on a small PHP project where my client repairs mechanical
devices for clients.  Their clients fill out their web form and then
would like to receive a PDF version of their Merchandise Return Label
for them to mail their device back for repair.

1. Form = Done
2. Web service call to USPS = Done
3. USPS is responding with the encoded PDF version of the label in
their response = Not sure what to do with it.

[A] Should I save it to the web server, and respond with a page that
points to it and gives additional instructions?
[B] Should I somehow trigger the PDF to be downloaded via the
browser, and give additional instructions to the user?
[C] ... some other solution that I haven't thought of.

I hate the thought of option 'A' as I never want to write a file to
the server.  I'd like to do 'B' but I'm not quite sure how to get the
flow to work properly.

Example code would be greatly appreciated.

Many thanks,
Kevin


[excessive quoting removed by server]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/5267e654.8090...@cullytechnologies.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to