Select to view content in your preferred language

FSV 1.3: My version of PDF Widget using AlivePDF

4964
21
09-01-2010 09:32 AM
BrianOevermann
Frequent Contributor
Attached is my version of a PDF widget to create portrait and landscape maps in the Sample Viewer 1.3, along with an example of each page orientation. It uses AlivePDF 0.1.5 RC and is written targeting Flash Player 10. No server-side components are required. The widget does not use a canvas element but consumes the map image directly.

The widget was based from the default print widget in the sample viewer and buttressed with a number of tips gleaned from the numerous AlivePDF discussions on these forums.

The result is not perfect, particularly the scaling of the map image into the pdf template. But that appears to be a shortcoming of the API/libraries in general. If anyone has come up with a method (preferably using the map image directly) to scale the map image to a defined "box" and still preserve aspect ratio, I would be grateful to see it!

I still need to refine my templates (and add a 'real', better quality logo) but I will wait until I get feedback from my users. For those that will inevitably ask for a pre-compiled .swf I will say that you really need to compile this yourself due to the tweaks needed for the template format. I tried to put most of the common elements into the config file, but your logo and disclaimer text will likely cause you to move some page elements around for best fit. My previous forum question regarding peoples' methods of creating AlivePDF templates generated zero response, so I can only assume that the trial-and-error method of positioning elements on the page is what everyone else is using. That took the bulk of the time creating this widget.

FYI, the two pdf examples were generated with the map jpg quality at 75%. The attached code has the quality set at 100%. For some reason the attachment uploader though my pdf files were over the 2 mb size limit even though they were only slightly over 1 mb. In comparing the two quality settings, I see little to no loss of quality but a huge file size difference. Something to think about...

I have no idea how well this will transfer to 2.0. I haven't had a chance to upgrade to ArcGIS 10 yet.

Enjoy, and I hope folks find this useful either in its entirety or for a jump-start. Hopefully this is just the start of my giving back to the community.

Brian
0 Kudos
21 Replies
by Anonymous User
Not applicable
Original User: TOVernon

I had found some code a while back that I used, it corrects the image size. It may need some tweaking.

   private function setPDFPageElements(docPDF:PDF, w:Number, h:Number):void
            {
            }

myPDF.addImage(printCanvas,15,(h - (w - 20)/ratio)/2 + 55,w - 20,(w - 20)/ratio,ImageFormat.JPG);
0 Kudos
KomanDiabate
Deactivated User
Aaron,
Thanks for the reply. I am not understanding how this procedure will fit in the PDFWidget code. Do you mind expanding on this idea. Thanks.
0 Kudos
by Anonymous User
Not applicable
Original User: TOVernon

I will spend some time on it this afternoon and see if I can incorportate the code into the widget

Aaron
0 Kudos
KomanDiabate
Deactivated User
Aaron, Thanks in advance. I appreciate all your help.
0 Kudos
by Anonymous User
Not applicable
Original User: lallen4585

I spent a little bit of time trying to adjust the map for screen resolution, but decided to just go with just Landscape map.  Still shows up wonky with some screen resolutions, so a change in the code that keeps the image to scale would be awesome! 

Here's the final product from our site as of the moment.
0 Kudos
AaronNash
Deactivated User
have not had any luck with the size issue, maybe someone else will chime in
0 Kudos
by Anonymous User
Not applicable
Original User: philipp37

Am trying to port this to SFV2.1.

I am not producing any compile-time errors but when I click the 'Generate PDF' button I receive the attached error...

I've also attached the mxml (just a bit too long to paste here) as PDFWidget.txt.


This is an extremely important widget since the out-of-the-box print widget is borderline useless.  Thanks for any thoughts/input!!!!
0 Kudos
MagalyC_
Deactivated User
Hi!

I have a problem with this widget, could you help me ?
http://forums.arcgis.com/threads/64368-PDF-with-image

Thanks!
0 Kudos
by Anonymous User
Not applicable
Original User: BrianO

Magaly,

A couple of thoughts...

If you are inserting the images in your layout code, have you embedded the images first?  My city logo embed code occurs around line 96 in my PDFWidget.mxml.  It looks like this:

    //embed logo image
    [Bindable]
   [Embed(source="assets/images/IssaquahLogo.jpg",mimeType="application/octet-stream")]
   private var myLogoJPG:Class;

Notice that my image is placed in the "assets/images" folder.

Also, in your signature block you note that you are using v3.0 of the Viewer and library.  I am still using v2.4 so I cannot comment on what changes, if any, may be necessary at v3.0 for this widget to function.  That said, you should explore the new print functionality available at 3.0 that promises to produce better (and easier) layouts plus, I believe, pdf output.

I am just starting the process of upgrading to Server 10.1, with upgrades to my viewers to follow.  I plan to retire my PDF widget in favor of the built in print functionality as I move to v3.0.
0 Kudos
MagalyC_
Deactivated User
Hi,

Thanks for the reply. I can't use the new functionality: I am in version 10.0 😕

What I'm not understand is that my widget goes well in local and test... 😞

I don't use Embed because my image is loaded since a XML config file. I dont't know if it's the best way but it works!

<mx:Image id="legendeImg" 
     x="345" y="20"
     source="{imageLegende}"
     width="80" height="313" visible="false"/>


imageLegende = configXML.legende || "assets/images/crea/vide.png";


myBitmapData = Bitmap(legendeImg.content).bitmapData;
 landPDF.addImage(new Bitmap(myBitmapData),null,xLegend,yLegend,wLegend,hLegend,0,1,true,tLegend,100);
0 Kudos