PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Tue Nov 04, 2025 9:45 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Jan 21, 2013 6:53 pm 
Offline

Joined: Mon Jan 21, 2013 6:32 pm
Posts: 2
Hello, I am not a fan of creating new topics, but even after 3 hours of searching, I am not able to find a solution for my problem.

I have an existing PDF which I want to use as a background image for new PDF I am creating. I have to create new PDF using migradoc document because of tables I need to create. So the question is. How can I convert an existing PDF page to image and then set it as background, so I will be able to create new migradoc document over it and insert some data.

Thanks everybody for your answers.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 22, 2013 9:25 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3136
Location: Cologne, Germany
No conversion needed, you can use pages from PDF files like you use images. With MigraDoc, just give the PDF file where you'd use BMP or JPG (add the page number like in "foo.pdf#17" to get page 17, not the first page).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 22, 2013 5:18 pm 
Offline

Joined: Mon Jan 21, 2013 6:32 pm
Posts: 2
So you mean like this? section.AddImage(template.pdf)? This just returns me "Image not found" error. And I'm not sure if I will be able to draw something over this image. What I need is to open PDF and create some migradoc section in it and then render result with my changes.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 23, 2013 9:16 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3136
Location: Cologne, Germany
Give the path of the PDF file to AddImage.
MigraDoc can create new PDF files, but it cannot add content to existing PDF files.

So either go the MigraDoc way and use AddImage to use pages from other PDF files as background images - or use the technique described in the Mix MigraDoc and PDFsharp sample.

Using AddImage is the easier way.
Here is sample code that places a textframe (same properties work for images):
viewtopic.php?p=3133#p3133

AddImage returns the image that was added to the document. Make sure to set "WrapFormat.Style = WrapStyle.Through;" for that image. Set "RelativeVertical = RelativeVertical.Page;" and don't use "Left = ShapePosition.Right;" from the sample.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 238 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