|
Rank: Newbie Groups: Member
Joined: 3/10/2011 Posts: 9
|
Hello,
I'm trying to render a pdf. The pdf consists of 4 elements, one background image and three text areas. I'm not finding a way to have the text portions to rest on top of the image, they always seem to get pushed down to the next page. How would I overcome this?
Thanks for any advice!!
-Brian Abel
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, The easiest way is to do overlapping is to use a different AcmRender to rende a separate layer. For example:
Code: C#
//Render something
AcmRender render1 = new AcmRender(startPage, startPos);
render1.Render(bottom_layer_acm_objects);
//Rendering something else on top of it
AcmRender render2 = new AcmRender(startPage, startPos);
render2.Render(top_layer_acm_objects);
When you do it this way, it's like feeding the same paper back to the printer again. Note that it uses the constructor that takes a PdfPage. This allows you to precisely specify where to start the layer. Hope this helps. Please feel free to let us know if this works for you. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/10/2011 Posts: 9
|
It's working pretty good so far, but I guess a follow up question: I've got this:
Code: Visual Basic.NET
Dim renderImage As New AcmRender(MyDoc, MyDocLayout)
Dim renderText As New AcmRender(MyDoc, MyDocLayout)
_MyContent.Children.Add(_myHeader)
_MyContent.Children.Add(_myBody)
_MyContent.Children.Add(_myFooter)
_MyImageContent.Children.Add(_myImage)
renderImage.Render(_MyImageContent)
renderText.Render(_MyContent)
: I'm now running into the issue where if the bill I'm trying to render is multiple pages long (images will be different as will be text per page). I'm trying to figure out where I set my loop up to overlay each image with the appropriate text
Code: Visual Basic.NET
Dim renderImage As New AcmRender(MyDoc, MyDocLayout)
Dim renderText As New AcmRender(MyDoc, MyDocLayout)
For Each _BillPage as BillPage in BillPageList
_MyContent.Children.Add(_myHeader)
_MyContent.Children.Add(_myBody)
_MyContent.Children.Add(_myFooter)
_MyImageContent.Children.Add(_myImage)
Next
renderImage.Render(_MyImageContent)
renderText.Render(_MyContent)
: When I render this, the first page comes out great, but the next pages come out as the images followed by the text so a four page document is about seven pages long. How am I messing this up? Thanks as always for your assistance. -Brian Abel
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, The key is the constructor you use when you create your AcmRender. In your code you give the AcmRender a PdfDocument object (MyDoc). In our code we give the AcmRender a PdfPage object (startPage). When you give AcmRender a PdfDocument, it will always start from the last page and keep creating new pages when it moves forward. On the other hand, when you give it a PdfPage, it will start exactly from the page you specify. When you just create a new PdfDocument, it does not have any pages. So the code will be something like this:
Code: C#
//Create a new PdfDocument
PdfDocument doc = new PdfDocument();
//Add a blank page as the first page
PdfPage firstPage = doc.Pages.Add();
//IMPORTANT: Use firstPage instead of doc to create AcmRender
AcmRender render1 = new AcmRender(firstPage, 0);
AcmRender render2 = new AcmRender(firstPage, 0);
//Then go on with your loop....
.....
Hope this helps. Thanks!
|
|