PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Assertion "Raw string contains invalid character with value
http://forum.pdfsharp.com/viewtopic.php?f=2&t=862
Page 1 of 1

Author:  kostadinnm [ Tue Sep 08, 2009 12:34 pm ]
Post subject:  Assertion "Raw string contains invalid character with value

Hi.
I am using the PdfSharp Library in a project, trying to create a pdf document from multiple paged tiff document. My code runs correctly, but at my mate's machine an Assertion warning message pops up: "Raw string contains invalid character with a value > 255."
Here is the code i use:

System.Drawing.Image img = null;
System.Drawing.Imaging.FrameDimension frameDimention = null;
int frameCount = 0;

PdfSharp.Drawing.XImage pdfimage = null;

img = System.Drawing.Image.FromFile(source);
frameDimention = new System.Drawing.Imaging.FrameDimension(img.FrameDimensionsList[0]);
frameCount = img.GetFrameCount(frameDimention);
PdfSharp.Pdf.PdfDocument pdfDocument = new PdfSharp.Pdf.PdfDocument();

for (int i = 0; i < frameCount; i++)
{
img.SelectActiveFrame(frameDimention, i);

pdfDocument.Pages.Add(new PdfSharp.Pdf.PdfPage());
using (PdfSharp.Drawing.XGraphics xgr =
PdfSharp.Drawing.XGraphics.FromPdfPage(pdfDocument.Pages[i]))
{

pdfimage = img;//equal to XGraphics.FromGdiPlusImage()

pdfDocument.Pages[i].Width = XUnit.FromPoint(img.Size.Width);
pdfDocument.Pages[i].Height = XUnit.FromPoint(img.Size.Height);
xgr.DrawImage(pdfimage, 0, 0, img.Size.Width, img.Size.Height);
}
}

using (MemoryStream ms = new MemoryStream())
{
pdfDocument.Save(ms);
byte[] pdfAlteredDocBytes = ms.ToArray();
pdfDocumentAsBinary = new System.Data.Linq.Binary(pdfAlteredDocBytes);
}

It seems like in the red-colored Save method something happens. I follwed the assertion up to the overriden GetBytes method of the RawEncoding class. I link the image with the assertion shown - http://img7.imageshack.us/img7/4899/errun.png.
In fact if the assertion is ignored it works. I really don't understand how this could happen on other's machines?! I welcome any help!!!

Guys, any help?!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/