|
PDFsharp - moved to http://forum.pdfsharp.net/ Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
|
Important Notice:
We regret to inform you that our free phpBB forum hosting service will be discontinued by the end of June 30, 2024.
If you wish to migrate to our paid hosting service, please contact billing@hostonnet.com.
View previous topic :: View next topic |
Author |
Message |
adam
Joined: 05 Apr 2008 Posts: 1
|
Posted: Sun Apr 06, 2008 11:23 am Post subject: PagePreview problem |
|
|
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 |
|
|
dvh
Joined: 14 Oct 2008 Posts: 4
|
Posted: Tue Oct 14, 2008 8:14 pm Post subject: |
|
|
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 |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Wed Oct 15, 2008 8:23 am Post subject: |
|
|
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 |
|
|
|
|
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
|
|