Q: That code definitely shows the page with a 1/2 inch of whitespace
at the bottom. But is it editable? I can't seem to write any text in
the new area. Here is the code I'm using to write a text element:
Page pg = doc.GetPage(1);
Rect box = pg.GetMediaBox();
box.y1 -= 32;
box.Update();
box = pg.GetCropBox();
box.y1 -= 32;
box.Update();
ElementBuilder eb = new ElementBuilder();
ElementWriter writer = new ElementWriter();
Element elmt; Font f = Font.CreateTrueTypeFont(id, "c:\\windows\\fonts\
\arial.TTF", true, false);
writer.Begin(pg);
elmt = eb1.CreateTextBegin(f, 12);
writer.WriteElement(elmt);
elmt = eb.CreateTextRun("Test Text");
elmt.SetTextMatrix(1, 0, 0, 1, 216, -15);
writer.WriteElement(elmt);
writer.WriteElement(eb.CreateTextEnd());
writer.End();
If I set the v coordinate of SetTextMatrix to 0, the text shows 1/2
inch above the bottom of the page. If I set the v coordinate to a
negative value, the text disappears, instead of writing in the new
whitespace area. I'm obviously missing something on how you can
insert data elements into the new area that was created.
-----------
A: The problem is that the page origin does not coincide anymore with
[0, 0]. To solve this issue when adding new content to you may want to
refer the following article:
http://groups.google.com/group/pdfnet-sdk/browse_thread/thread/10190611076bd2cd/eb7382f49c0ee0fe
or search for "add new content to an existing (rotated/cropped) PDF
page" in
http://groups.google.com/group/pdfnet-sdk/
For users of PDFNet v4.1 or above the simplest solution is to use
writer.BeginNormalized(page) instead of more generic
writer.Begin(page).