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 

PagePreview problem

 
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
adam



Joined: 05 Apr 2008
Posts: 1

PostPosted: Sun Apr 06, 2008 11:23 am    Post subject: PagePreview problem Reply with quote

Hi,

I've got problem with pdf preview.

This is my C# code:

public partial class PrintForm : Form, IPrintForm
{
private PagePreview.RenderEvent renderEvent;
private System.IO.MemoryStream memStream;
public PrintForm()
{
InitializeComponent();
}
public void ShowPrintForm(System.IO.MemoryStream mem)
{
this.memStream = mem;
this.renderEvent = new PagePreview.RenderEvent(Render);
pagePreview.SetRenderEvent(this.renderEvent);
this.ShowDialog();
}
private void Render(XGraphics gfx)
{
PdfDocument document = PdfReader.Open(this.memStream);
gfx = XGraphics.FromPdfPage(document.Pages[0]);
}

...

}

I'm using VS 2008 Express Edition with PDFSharp v.1.0.898.0
PDFSharp was compiled under VS2008 and Runtime version 2.0.50727.
I'm using PdfSharp.Forms.PagePreview for viewing PDF's.

Problem: I'm receiving blank preview.

When I put this code in Render method:

PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Verdana", 20, XFontStyle.Bold);
gfx.DrawString("Hello, World!", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormat.Center);

.... everything works good.

When I try save document (in Render metod) ... everything works good.

Does anyone know what is wrong ?

Thanks
Adam S.
Back to top
View user's profile Send private message
dvh



Joined: 14 Oct 2008
Posts: 4

PostPosted: Tue Oct 14, 2008 8:14 pm    Post subject: Reply with quote

Hi,

Is there a solution for this problem already? I encountered a similar (if not the same) one - the following code does produce an empty preview.

Code:
        [...]
        PdfDocument outputDocument = new PdfDocument();
        PdfDocument inputDocument = PdfReader.Open(<<some_file_or_filestream>>, PdfDocumentOpenMode.Import);
               
        for (int i = 0; i < inputDocument.PageCount; i++) {
            PdfPage page = inputDocument.Pages[i];
            outputDocument.AddPage(page);
        }

        for (int i = 0; i < outputDocument.PageCount; i++) {
            PdfPage page = outputDocument.Pages[i];
            gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append);
        }
        [...]


The code above is an excerpt from the Preview sample Render(XGraphics) method which I modified.

Any help would be much appreciated. TIA
Back to top
View user's profile Send private message
Thomas Hoevel



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

PostPosted: Wed Oct 15, 2008 8:23 am    Post subject: Reply with quote

Hello!

It's by design that only XGraphics show in Preview, not imported PDF pages.

Imported pages will show when a PDF file is created (directly or indirectly from the Preview dialogue).

Workaround: Create PDFs directly and show them with Adobe Reader.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
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