In today’s blog post we’re going to show you the codes needed to convert a GIF shipping label into a PDF document.
We’re going to use pages, classes, and controllers.
APEX Class
The first method we need to look at is regenerateGifToPdfLabel (line 2). The steps are as follows:
The createPDFLabels (line 25) method in step 3 above calls the generatePDFLabel method (line 35).
Next create a new attachment object pdfLabel, which will be the PDF file (line 36). Line 38 is where we reference our VisualForce page, that will contain the original GIF file. The VisualForce page code can be found at the bottom of this post.
Line 41 sets the Body of the new attachment object as the blob that is returned from the standard SalesForce method getContentAsPDF();.
APEX Controller
Line 6-7 basically set the variable that will be used in the VisualForce page.
VisualForce Page
Line 25 is where the GIF shipping label is inserted, which is then rendered as a pdf from the code we have already looked at from above.
Happy coding.