We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Font error in Adobe Reader when stamping PDF on PDF

Hi,


When stamping a PDF file with a PDF file (ASP.NET) I’m receiving sometimes (depending on the Stamp file) when opening the new file with Adobe Reader this error:

Cannot find or create the font ‘SWUCQY+Windings00Enc’. Some characters may not display or print correctly.

The strange thing about it, is that both sourcefile and stampfile can be openen also in a browser without receiving the error.

This is my code:

protected void Page_Load(object sender, EventArgs e)
{
sFolder = // folder and file
FileStream fs = new FileStream(sFolder, FileMode.Open, FileAccess.Read, FileShare.Read);
byte[] df = stampToPdf(“stampfile”, ref fs); // stampfile is phyical path to pdf stamp
fs.Close();
// Transmit the buffer in the response
Response.Expires = 0;
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = “application/pdf”;
Response.BinaryWrite(df);
Response.Flush();
Response.End();
}

public byte[] stampToPdf(string stamp, ref FileStream fs)
{
MemoryStream ms = new MemoryStream();
if (File.Exists(stamp))
{
Aspose.Pdf.Kit.Stamp aStamp = new Aspose.Pdf.Kit.Stamp();
aStamp.BindPdf(stamp, 1);
aStamp.IsBackground = true;
PdfFileStamp stamper = new Aspose.Pdf.Kit.PdfFileStamp(fs, ms);
stamper.AddStamp(aStamp);
stamper.Close();
}
//create new Bite Array
byte[] biteArray = new byte[ms.Length];
//Set pointer to the beginning of the stream
ms.Position = 0;
//Read the entire stream
ms.Read(biteArray, 0, (int)ms.Length);
ms.Close();
return biteArray;
}

The code works with most pdf stamp files…but not with all …

Any idea or probably a better solution ?

Regards,

Jan

Hello Jan,

Thanks for using our products.

Can you please share the source PDF documents which are causing these issues, so that we can test the scenario at our end. We apologize for this inconvenience.

Hi Nayyerv,

Find attached both stamp (test.pdf) and source

Regards,

Jan

Hi Jan,

Thanks for sharing the resource files.

I have tested the scenario using Aspose.Pdf for .NET 6.2.0 and I am unable to notice any problem. Can you please share which version of product you are using ?
For your reference, I have also attached the resultant PDF files that I have generated. We apologize for this inconvenience.

Hi

Thank you for your time.

Both files attached don't look stamped together. And also. I'm still using the pdf.kit dll. There's no version 6.2 availaible.

Can you please provide me a working example with both original files stamped together ?

I've included the stamped pdf with it. You can check the error when opening with acrobat reader

Regards,

Jan

Hello Jan,

Please ignore my previous post as in earlier post, I had an understanding that you are trying to add some text as watermark stamp but now I have realized that you are trying to stamp pages of one PDF document to other document. I have again tested the scenario using Aspose.Pdf for .NET 6.2.0 and as per my observations, when I have tried viewing the resultant PDF document in Adobe Reader X (v10.1.1), I am unable to notice any error. For your reference, I have also attached the resultant PDF document that I have generated. Can you please try viewing it and acknowledge that the error still persists or its resolved.

FYI, Since the release of Aspose.Pdf for .NET 6.0.0, Aspose.Pdf.Kit for .NET has been merged into Aspose.Pdf for .NET, so now this single component provides the capabilities to create as well as manipulate existing PDF documents. I would recommend you to please try migrating to this new product as the support for separate version of Aspose.Pdf.Kit for .NET will be stopped after October 2011. Please visit the following links for information on

Thank you Nayyer for your time…


I’m totally confused now (not your fault though)

After your initial post I’ve changed the dll and the code to stamp both pdf files using the 6.2 aspose.pdf dll this way:

public partial class main_pdfFactuur : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Aspose.Pdf.License lc = new Aspose.Pdf.License();
lc.SetLicense(Server.MapPath("~/Licences/Aspose.Total.lic"));

string sFolder = Request.Params[“folder”];
string sStampFolder = Request.Params[“stampfolder”];
string sPath = iWiseC.myUtils.getKlant(“cPdfPath”);
string PdfFullname = string.Format("{0}\{1}", sPath, sFolder);
string StampFullname = sStampFolder;
sFolder = Path.Combine(PdfFullname.Replace(“iWise”, “iwise”), sFolder);
FileStream fs = new FileStream(sFolder, FileMode.Open, FileAccess.Read, FileShare.Read);
FileStream fsstamp = new FileStream(StampFullname, FileMode.Open, FileAccess.Read, FileShare.Read);
byte[] df = StampPdfNew(fsstamp, fs);
fs.Close();
// Transmit the buffer in the response
Response.Expires = 0;
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = “application/pdf”;
Response.BinaryWrite(df);
Response.Flush();
Response.End();
}

private static MemoryStream FileStream2MemoryStream(FileStream FStream)
{
MemoryStream MStream = new MemoryStream(Conversie.ToInt32(FStream.Length));
BinaryReader BinReader = new BinaryReader(FStream);
BinReader.BaseStream.Position = 0;
byte[] byteBuffer = BinReader.ReadBytes(Conversie.ToInt32(FStream.Length));
MStream.Write(byteBuffer, 0, Conversie.ToInt32(FStream.Length));
MStream.Position = 0;
return MStream;
}

public byte[] StampPdfNew(FileStream fsstamp, FileStream fsin)
{
MemoryStream fsout = new MemoryStream();
PdfFileStamp fileStamp = new PdfFileStamp(FileStream2MemoryStream(fsin), fsout);
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
//create stamp
stamp.BindPdf(fsstamp, 1);
//add stamp to PDF file
fileStamp.AddStamp(stamp);
//save updated PDF file
fileStamp.Close();
fsout.Position = 0;

byte[] ar = Memorystream2ByteArray(fsout);

System.IO.File.WriteAllBytes(@“c:\temp\jan.pdf”,ar);

fsout.Close();

return ar;
}

private static byte[] Memorystream2ByteArray(Stream ms)
{
//create new Bite Array
byte[] biteArray = new byte[ms.Length];
//Set pointer to the beginning of the stream
ms.Position = 0;
//Read the entire stream
ms.Read(biteArray, 0, (int)ms.Length);
ms.Close();
return biteArray;
}
}

The error is still there though. Even when saving the file to the disk (I’ve attached the stamped file in my previous post)

But your file I can open without any error. Is it possible for you to compare both your generated file and my attached file ?

I’m lost … :frowning:

FYI. I’m programming on a Windows 7 professional machine. Just to exclude operating system problems…

Jan

Hi Jan,

I
have again tested the scenario and I am able to reproduce the same problem. I have observed that the problem is occurring when using Stream object to stamp the PDF documents and in my earlier attempt, I accessed files using strings. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWNET-30912. We will investigate this
issue in details and will keep you updated on the status of a correction.
<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””><span style=“font-size:10.0pt;
font-family:“Arial”,“sans-serif””>

We apologize for your inconvenience.


The issues you have found earlier (filed as PDFNEWNET-30912) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.