Select to view content in your preferred language

Print to PDF File - AlivePDF

3451
7
06-23-2010 12:12 PM
BrentKastor
Emerging Contributor
Hello,

I am stumped on this crazy AlivePDF printing.  I think my trouble is with my asp page.  I have tried numerous asp/aspx pages, but seem to get the same error.  I am not terribly familiar with using asp/aspx pages, so that doen't help any.  Is there something special I need to do to make the asp/aspx file work?

http://gis.coweta.ga.us/cctax/index.html  <--Here is my site.

The print button is in the upper left hand corner - kind of hidden...

Here is my mxml...
   import org.alivepdf.pdf.PDF;
   import org.alivepdf.images.ImageFormat;
   import org.alivepdf.display.Display;
   import org.alivepdf.colors.RGBColor;
   import org.alivepdf.fonts.FontFamily;
   import org.alivepdf.saving.Download;
   import org.alivepdf.saving.Method;
   import org.alivepdf.fonts.Style;
   import org.alivepdf.layout.Size;
   import org.alivepdf.layout.Orientation;
   import org.alivepdf.layout.Unit;
  
  // Begin - Print
  private var myPDF:PDF;
  private function doPrintPDF():void
  {
   var date:Date = new Date();
   var w:Number = myMap.measuredMinWidth;
   var h:Number = myMap.measuredHeight;
       w=w+10; // adjust width of myMap in order to fit print
    myPDF = new PDF(Orientation.LANDSCAPE,Unit.POINT,
         new Size([h+80,w+10],"dynamicSize",[(h+80)/96,(w+10)/96],[(h+80)*3.779527559,(w+10)*3.779527559]));
    myPDF.setDisplayMode(Display.DEFAULT);
    myMap.scaleBarVisible = true;
     myMap.zoomSliderVisible = false;
    myPDF.addPage();
      myPDF.setFont(FontFamily.ARIAL, "B", 18);
       myPDF.addText("Coweta County, GA", 10, 35);
       myPDF.setTitle("CowetaCountyGIS");
       myPDF.setFont(FontFamily.ARIAL, "B", 12);
       myPDF.addText(date.toDateString()+" "+date.toTimeString(), 10, h+66);
       myPDF.addText("Developed by Coweta County GIS", w-190, h+66);
       myPDF.lineStyle(new RGBColor (0x000000), 1, .3, 1,CapsStyle.SQUARE, JointStyle.MITER );
      myPDF.drawRect(new Rectangle (10,50,w-10,h));
    
    try
    {
     myPDF.addImage(myMap,10,50,0,0,ImageFormat.JPG);
    }
    catch (error:Error)
    {
     Alert.show(error.message.toString());
    }
    myPDF.save(Method.REMOTE, "http://gis.coweta.ga.us/CreatePDF/cctax/default.aspx",Download.INLINE,"myMap.pdf");
       myMap.zoomSliderVisible = true;
   }
  
Tags (2)
0 Kudos
7 Replies
IrfanClemson
Frequent Contributor
I target FP version 10+ and so don't need to use any server-side script for PDF generation. The user gets a file download link once clicking on a 'Print' button within my Flex app interface.
0 Kudos
CarmenDurham
Frequent Contributor
Hey Brent,

It is probably something simple. 

When it happened to me, I had forgotten to set the default content web page for the createPDF to be the create.aspx (which is what it is in my case vs. default.aspx).  Have you "created" the web app in IIS on the CreatePDF folder or the cctax folder? 

All of my alive pdf files (.aspx, web.config, etc) are directly within the CreatePDF folder whereas yours are in the CreatePDF/cctax folder (based on your line of code).  I am not sure if that extra level of directory structure is messing anything up.

I am like you, just getting something to work. Not sure if it is the most efficient way!

Carmen Talley Durham
City of Greenville, SC
0 Kudos
BrentKastor
Emerging Contributor
Hey Brent,

It is probably something simple. 

When it happened to me, I had forgotten to set the default content web page for the createPDF to be the create.aspx (which is what it is in my case vs. default.aspx).  Have you "created" the web app in IIS on the CreatePDF folder or the cctax folder? 

All of my alive pdf files (.aspx, web.config, etc) are directly within the CreatePDF folder whereas yours are in the CreatePDF/cctax folder (based on your line of code).  I am not sure if that extra level of directory structure is messing anything up.

I am like you, just getting something to work. Not sure if it is the most efficient way!

Carmen Talley Durham
City of Greenville, SC


Hey Carmen - I hope all is well in Greenville.  It looks like I will be heading up that way in October for a wedding.  I always look forward to a trip to Greenville 🙂

You are correct about it being something simple.   I went into IIS and did some poking around - changed the directory to CreatePDF in place of "CreatePDF/cctax" - and success 🙂  I had already created a virtual directory in IIS using "C:\Inetpub\wwwroot\CreatePDF" Now I am getting a pdf that is about 10 pixels wide - that should be easy to fix 🙂  Talk to you soon!

Brent
0 Kudos
BrentKastor
Emerging Contributor
Hey Brent,

It is probably something simple. 

When it happened to me, I had forgotten to set the default content web page for the createPDF to be the create.aspx (which is what it is in my case vs. default.aspx).  Have you "created" the web app in IIS on the CreatePDF folder or the cctax folder? 

All of my alive pdf files (.aspx, web.config, etc) are directly within the CreatePDF folder whereas yours are in the CreatePDF/cctax folder (based on your line of code).  I am not sure if that extra level of directory structure is messing anything up.

I am like you, just getting something to work. Not sure if it is the most efficient way!

Carmen Talley Durham
City of Greenville, SC


Could I see your create.aspx file?
0 Kudos
BrentKastor
Emerging Contributor
Could I see your create.aspx file?


Never Mind - I think I have it working - now I just need to move the print button to somewhere more respectable 🙂
0 Kudos
BrentKastor
Emerging Contributor
I would also like to insert an image located on my server.  Is there an easy way to insert a jpg or gif into the pdf?
0 Kudos
CarmenDurham
Frequent Contributor
Brent,

I have a logo at the upper left corner of the pdf.  This is the line of code that is in the portion where you are generating the pdf:

reportPDF.addImageStream(new gislogojpg() as ByteArray, 10, 10, 20, 24, 1, ResizeMode.NONE);


The following needs to be placed where you are declaring variables:

[Embed( source="images/GandGIS65a.jpg", mimeType="application/octet-stream" )]
private var gislogojpg:Class;

I copied the image to an "images" folder that is a part of the Flex Project.  Although if you had a "virtual directory" of images on your web server, I would guess you could use that as a source.  We link to photos from a Sample Flex Viewer app using images stored in a folder that we have set to a Virtual Directory in IIS.
0 Kudos