Umbraco poll package sourcecode 0
The last couple of weeks I’ve gotten lots of request for the poll package sourcecode.
So I’ve added the sourcecode to the poll project page on our.umbraco.org (attached files).
Enjoy!
The last couple of weeks I’ve gotten lots of request for the poll package sourcecode.
So I’ve added the sourcecode to the poll project page on our.umbraco.org (attached files).
Enjoy!
Some time ago I created a solution for generating pdf documents from your umbraco content (and from the outputted html). I always wanted to make a package out of this but since the project relies on the commercial pdf generating library ABCpdf this isn’t possible. The main reason for using ABCpdf is that it’s html to pdf options are pretty decent.
So instead of releasing a package I’ll share the sourcecode and I’ll give an overview of how to use it.
Download: PDFGen sourcecode
Once you have ABCpdf installed (it’s possible to download a trail and you can also apply for a free license) the installation is just a mather of dropping some files in your umbraco instance.
First you’ll need to define a pdf template, this can be done in the PDFGen.config file which should
be in the /config folder.
Lets look at an example config file:
<?xml version=”1.0″ encoding=”utf-8″ ?>
<PDFGen PermitPrint=”False” PermitExtractContent=”False”>
<!– Header–>
<Text FontName=”Arial” FontSize=”12″ FontColor=”0,0,0″ X1=”20″ Y1=”40″ X2=”500″ Y2=”700″
IsRecurring=”true”>my header text</Text>
<Image File=”/media/950/joblistpdfhead.jpg” X=”20″ Y=”670″ Width=”570″ Height=”100″ IsRecurring=”true”/>
<!– Content –>
<Property RequestParam=”test” PropertyAlias=”title;@createDate” FontName=”Arial” FontSize=”18″
FontColor=”0,0,0″ X1=”25″ Y1=”620″ X2=”500″ Y2=”650″ IsRecurring=”false”>{0} - {1}</Property>
<Property RequestParam=”" PropertyAlias=”info” FontName=”Arial” FontSize=”11″ FontColor=”0,0,0″ X1=”25″
Y1=”180″ X2=”530″ Y2=”630″ IsRecurring=”false”></Property>
<Property RequestParam=”" PropertyAlias=”linkURL” FontName=”Arial” FontSize=”11″ FontColor=”0,0,0″
X1=”40″ Y1=”715″ X2=”520″ Y2=”740″ IsRecurring=”false”></Property>
<!– Footer –>
<Text FontName=”Arial” FontSize=”6″ FontColor=”0,0,0″ X1=”25″ Y1=”20″ X2=”500″ Y2=”30″
IsRecurring=”true”>Copyright mysite 2009 — All Rights Reserved.</Text>
</PDFGen>
After the xml declaration (yes the config file is an xml file) you have the PDFGen root node.
On this node you can set wether the generated pdf files are printable and if it is possible to extract
content (copy,paste).
<PDFGen PermitPrint=”False” PermitExtractContent=”False”>
The child nodes of the root PDFGen node will be used to define the pdf. There are a couple of
possibilities:
<Text FontName=”Arial” FontSize=”12″ FontColor=”0,0,0″ X1=”20″ Y1=”40″ X2=”500″ Y2=”700″
IsRecurring=”true”>my header text</Text>
A text node is used to add some static text on the pdf document it has several attributes
<Image File=”/media/950/joblistpdfhead.jpg” X=”20″ Y=”670″ Width=”570″ Height=”100″ IsRecurring=”true”/>
An image node is used to add an image to the pdf document.
An overview of it’s attributes:
<Property RequestParam=”test” PropertyAlias=”title;@createDate” FontName=”Arial” FontSize=”18″
FontColor=”0,0,0″ X1=”25″ Y1=”620″ X2=”500″ Y2=”650″ IsRecurring=”false”>{0} – {1}</Property>
A property node is used to add umbraco content node property data to the pdf document.
An overview of it’s attributes:
The innertext can be used to add some static text around the property or if you have multiple
propertyaliases you must define how they will be placed (simular to string.format).
<RenderedOutput RequestParam=”" Template=”" X1=”25″ Y1=”620″ X2=”500″ Y2=”650″ IsRecurring=”false” />
This will fetch the rendered output of a page, if no requestparam is used it will use the id one and if no template alias is defined it will use that default template of that page.
An overview of it’s attributes:
Once installed and if you have a working config file. You can use pdfgen by calling /umbraco/pdfgen.aspx?id=1234 (the id is the id of the umbraco document).
If you have defined other RequestParams in your config file (like headerid) you just need to do:
/umbraco/pdfgen.aspx?id=1234&headerid=2345
It’s also possible to have multiple config files (just copy the pdfgen.config) if you want to use anohter config file you can do it like this:
/umbraco/pdfgen.aspx?id=1234&pdfconfig=pdfconfigcopy.config
pdfconfigcopy.config is the filename of the configfile (must be in the /config dir)