.comment-link {margin-left:.6em;}

kHSw

Wednesday, April 12, 2006

Form converted to .NET 2.0 resizes when rebuilding the project

Today I converted a small project to .NET 2.0.

I had my main form open in the designer when I did a rebuild of the project. The height of my form changed all of a sudden. If I ran my form, the anchoring was completely messed up!

After some testing I removed the MainMenu of my form and the weird behaviour had gone. I had to replace the MainMenu with a MenuStrip...

Monday, April 10, 2006

Dolmen Jobevent 26 april 2006

Ben jij een ervaren IT-er op zoek naar een nieuwe uitdaging? Dan is er een toekomst voor jou weggelegd bij Dolmen.Een job vol afwisseling, een stabiele werkomgeving, een'no nonsense' bedrijfscultuur, state-of-the-art ICT-oplossingen en dynamische medewerkers.
Ontdek alles over Dolmens bedrijfscultuur, jobinhoud, doorgroeimogelijkheden, competentiemanagement,… op Dolmens jobevent op 26 april 2006.


http://www.dolmen.be/jobevent

Friday, April 07, 2006

Merge PDF Files using iTextSharp

iText# (iTextSharp) is a port of the iText open source java library written entirely in C# for the .NET platform. iText# is a library that allows you to generate PDF files on the fly. It is implemented as an assembly.

The code of the class I've written uses iText# and is based on the example code (Console Application) that can be found on
http://itextsharp.sourceforge.net/examples/Concat.cs . However, this code seems to target an out of date version of iText# and can't be compiled without fixing some lines...

This C#-class will allow you to merge multiple PDF's to one big PDF-file:

// Based on : http://itextsharp.sourceforge.net/examples/Concat.cs
using System;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
public class PdfMerge
{
public static void MergeFiles(string destinationFile, string[] sourceFiles)
{
try
{
int f = 0;
// we create a reader for a certain document
PdfReader reader = new PdfReader(sourceFiles[f]);
// we retrieve the total number of pages
int n = reader.NumberOfPages;
Console.WriteLine("There are " + n + " pages in the original file.");
// step 1: creation of a document-object
Document document = new Document(reader.GetPageSizeWithRotation(1));
// step 2: we create a writer that listens to the document
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(destinationFile, FileMode.Create));
// step 3: we open the document
document.Open();
PdfContentByte cb = writer.DirectContent;
PdfImportedPage page;
int rotation;
// step 4: we add content
while (f < sourceFiles.Length)
{
int i = 0;
while (i < n)
{
i++;
document.SetPageSize(reader.GetPageSizeWithRotation(i));
document.NewPage();
page = writer.GetImportedPage(reader, i);
rotation = reader.GetPageRotation(i);
if (rotation == 90 rotation == 270)
{
cb.AddTemplate(page, 0, -1f, 1f, 0, 0, reader.GetPageSizeWithRotation(i).Height);
}
else
{
cb.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);
}
Console.WriteLine("Processed page " + i);
}
f++;
if (f < sourceFiles.Length)
{
reader = new PdfReader(sourceFiles[f]);
// we retrieve the total number of pages
n = reader.NumberOfPages;
Console.WriteLine("There are " + n + " pages in the original file.");
}
}
// step 5: we close the document
document.Close();
}
catch(Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e.StackTrace);
}
}
}


 
Stefanie Worm is het liefste vrouwtje van de wereld.
Melina is de liefste schatsie van de wereld (Erik De Maeyer).