So, I hacked together a program recently, designed to put together a pdf composed of 3.5x2 Business cards (10 to a sheet) for printing. I did this using abcPDF by WebSuperGoo at the direction of my employer.
Well, it turns out that the client doesn't like to use .dlls that require installed licenses. Their server admin pointed us to PDFsharp, I'm assuming because the OpenSource license doesn't cause trouble if you have to migrate servers. Whatever their reasoning, I now have to scrap my old code and write mostly new code.
Code:
private static void singleton(Doc nProgress, PDFTable nTable, int position, String name, bool isPTA, String license, String expireDate, String[] fieldNames)
{
XImage cardImage = new XImage();
String temp = System.Web.HttpContext.Current.Server.MapPath("Singleton.jpg");
cardImage.SetFile(temp); //edit this with the path for the card image.
nTable.AddImage(temp, cardImage, false, false);
// nTable.AddImage(cardImage, false);
int currentPoint = position * 4;
for (int x = 0; x < 4; x++)
{
Field editing = nProgress.Form[fieldNames[currentPoint]];
switch (x)
{
case 0: editing.Value = name;
break;
case 2: editing.Value = license;
break;
case 3: editing.Value = expireDate;
break;
case 1: if (isPTA)
{
editing.Value = "is Licensed as a Physical Therapist Assistant";
}
else
{
editing.Value = "is Licensed as a Physical Therapist";
}
break;
default:
break;
}
currentPoint++;
}
return;
}
public static String PrintSingle(int position, String name, String license, String expireDate, bool isPTA)
{
Doc toPrint = new Doc();
toPrint.Read(System.Web.HttpContext.Current.Server.MapPath(blankPath));
toPrint.Rect.Top = 756;
toPrint.Rect.Bottom = 36;
toPrint.Rect.Left = 36;
toPrint.Rect.Right = 576;
PDFTable theTable = new PDFTable(toPrint, 2);
theTable.SetColumnWidths(new double[] {252, 252});
for (int y = position / 2; y >= 0; y--)
{
theTable.NextRow();
theTable.NextCell();
XImage cardImage = new XImage();
String temp = System.Web.HttpContext.Current.Server.MapPath("FillerImage.jpg");
cardImage.SetFile(temp); //edit this with the path for the card image.
theTable.AddImage(temp, cardImage, false, false);
//theTable.AddImage(cardImage, false);
}
String[] fieldnames = toPrint.Form.GetFieldNames();
Array.Sort(fieldnames);
if (position % 2 == 1)
{
theTable.NextCell();
}
singleton(toPrint, theTable, position, name, isPTA, license, expireDate, fieldnames);
toPrint.Flatten();
toPrint.Save(savePath);
return savePath;
}
That above is my code. I was taking a blank PDF filled with fields (for Name, license no., etc), finding out where on the PDF I needed to start my printing, etc.
I guess what I'm asking is, is there functionality in PDFsharp similar to what abcPDF does? If so, can someone point me in the direction I should start?