PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Apr 24, 2024 5:50 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Jul 28, 2014 12:55 pm 
Offline

Joined: Mon Jul 28, 2014 12:44 pm
Posts: 3
Hi there

I have a pdf that is generated from visio.
It stretches several A4 pages widths to the right and down.
The document when opened in pdf viewer shows a single page.

I am looking for a way to import the pdf in PDFSharp and MigraDoc and then render the result with page breaks in A4 size, thus breaking the single doc into several A4 pages.

1. Can this be done?
2. Any example code?

I have tried but failed to achieve this so any help would be greatly appreciated.

Thank you
Theo


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 04, 2014 4:41 am 
Offline

Joined: Mon Jul 28, 2014 12:44 pm
Posts: 3
Anyone?

Any leads or suggestions?

Thank you


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 04, 2014 8:41 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
You can draw PDF pages larger than A4 on PDF pages of A4 size (or Letter or whatever). Do this in a loop and change the Top and Left position.

AFAIK PDFsharp does not currently support clipping. Draw white rectangles to simulate a white border (if needed).

The original single page PDF will be included only once in the new PDF file, so filesize should not grow excessively.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 04, 2014 9:06 am 
Offline

Joined: Mon Jul 28, 2014 12:44 pm
Posts: 3
Thank you for the response Thomas

What I am trying to achieve is so that when the document is opened in PDF viewer (or similar) it actually only shows a standard A4 page and you have x-y pages that you can navigate over.

Would it be possible to "create" pages from the src file so that it can be merged into a single file in another step? (i.e. export A4 page sizes and merge later)
Do you have a code snippet on how to import an existing PDF into MigraDoc?

Thank you
Theo


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 06, 2014 9:52 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Sounds like a job for PDFsharp, not MigraDoc.

I'd create one document with x-y pages in a single task. Creating individual A4 pages and merging them later will probably lead to a much bigger file.

Look at this sample:
http://www.pdfsharp.net/wiki/CombineDoc ... ample.ashx

You basically need these lines from variant 2:
Code:
// Get a graphics object for page1
gfx = XGraphics.FromPdfPage(page1);

// Set page number (which is one-based)
form1.PageNumber = idx + 1;

// Draw the page identified by the page number like an image
gfx.DrawImage(form1, new XRect(0, 0, form1.PointWidth, form1.PointHeight));
But your XRect will start at (0,0) only for the first page - at least one of the values will be negative for consecutive pages.

This way you will draw a big image onto a small page, so each page will show you a DIN A4 "viewport" of the big image.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 191 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