PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

multi-page pdf and new browser window - help!

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
pranayjoshi



Joined: 02 Feb 2009
Posts: 3
Location: Mumbai, India

PostPosted: Mon Feb 02, 2009 6:49 am    Post subject: multi-page pdf and new browser window - help! Reply with quote

Hi, I'm a PDFSharp (and asp.net) newbie. I've just got pdfsharp.dll and toyed around with a few things, like converting some text on my .aspx web page to pdf. I have a couple of questions:

1) Whenever I need to convert some text to pdf, I first create a blank pdf page, add it to my pdf document and then use DrawString (or some form of it, a wrapper) to paint my text on it. However, if the text is say, 10 pages, then using the same method, how do I ensure that I get a pdf document that is 10 pages long? do I have to check if the text will fit in one page, or two pages and manually do everything.. or is there a way with which I can just give the text, the font, the size etc, get pdfsharp to compute the no. of pages it'll need to fit the text in and give me a multi-page pdf document?

2) I have a textbox on my .aspx page and a button next to it which says 'Export to pdf'. the end user has to enter some text in the textbox and then click on the button to see his text in pdf format. right now, my browser (internet explorer 7) is converting the text to pdf in the same window. how do I get it to open the pdf in a new browser window?
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Mon Feb 02, 2009 10:35 am    Post subject: Reply with quote

Hi!

Re 1)
Use MigraDoc.

Re 2)
Look here:
http://pdfsharp.s3.bizhat.com/viewtopic.php?t=353&highlight=contenttype
The keywords are 'target="_blank"', "Response.ContentType" and "Content-Disposition".
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
pranayjoshi



Joined: 02 Feb 2009
Posts: 3
Location: Mumbai, India

PostPosted: Tue Feb 03, 2009 6:57 am    Post subject: Reply with quote

Hi Thomas, thanks a lot for your prompt reply, you're a legend!

Question no. 2 has been resolved Smile

However, I'm still having some trouble creating multi-page pdf documents. I checked out your MixMigraDocAndPdfSharp sample, and its got the following 2 snippets of code:

// code snippet #1
static void SamplePage1(PdfDocument document)
{
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);


// code snippet #2
// You need always a MigraDoc document for rendering.
Document doc = new Document();
Section sec = doc.AddSection();
// Add a single paragraph with some text and format information.
Paragraph para = sec.AddParagraph();

This still renders the document page by page, one paragraph at a time. What I'm looking for is to just input something like 10 pages of text, and get a 10-page pdf document in return.

My final objective is to export some content on a sharepoint portal to PDF. The challenge is to export it while keeping the look and feel (.aspx page in sharepoint, rendered using html and css) as similar to the original sharepoint page as possible. I'm not sure about the best approach to do this. Is there a way to export html+css to pdf directly (by parsing html+css to preserve the look and feel and then converting the required text to pdf)?
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Tue Feb 03, 2009 9:24 am    Post subject: Reply with quote

When you create a MigraDoc document, you add paragraphs and manual page breaks.

When the document is rendered, MigraDoc determines the number of pages that is needed.

You're dealing with a "pageless" MigraDoc document and the "layouted" PdfDocument - and MigraDoc tells you how many pages are needed.
And you only have to go this way if you want to improve the pages created by MigraDoc with some PDFsharp calls.

I thought that's what you need.

You can call AddSection in a loop from 1 through 10,000 and see how many pages MigraDoc will create.

If you add nine manual page breaks you'll get at least 10 pages. Maybe more if one logical page has too much text for a physical page.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
pranayjoshi



Joined: 02 Feb 2009
Posts: 3
Location: Mumbai, India

PostPosted: Tue Feb 03, 2009 10:14 am    Post subject: Reply with quote

Hi Thomas, thanks for clearing that up! It worked great. SmileSmileSmile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com