PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jun 16, 2024 3:30 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Jul 16, 2010 5:59 pm 
Offline

Joined: Fri Jul 16, 2010 5:54 pm
Posts: 1
Hi there!

I was trying to save a Grid(that's a Child from a StackPanel) into a pdf page, so I transformed my grid into a bitmapsource and then created a XImage from that bitmapsource

the code of what i'm trying to do..:

foreach (UIElement ui in StackPanel.Children)
{
stack.Children.Remove(ui);
XGraphics gfx = XGraphics.FromPdfPage(document.AddPage());
RenderTargetBitmap bmp = new
RenderTargetBitmap(816, 1123, 96, 96,PixelFormats.Pbgra32);
bmp.Render(ui);
gfx.DrawImage(XImage.FromBitmapSource(bmp), new Point(0, 0));
}

document.Save(filename);
Process.Start(filename);
...

the problem is that when i'm trying to generate a bitmap from the children of the stack panel, just the first child is generating a page with content, but the is generating nothing in the page, what I'm doing wrong? Is that the right way for doing that?

Thanks in advance


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 19, 2010 7:16 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
Marcelo wrote:
Is that the right way for doing that?

At least it's not the best way. PDF is designed for vector data.
You'd better re-create the output using PDFsharp or MigraDoc to get a PDF document that contains text, not screen copy images (unless that's what you want/need).

I don't know why your code is not working.
Maybe the error is not in the small snippet we see ...

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 161 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group