New PdfFileStamp constructor and methods result in no stamp on the PDF. V7.5

I think I reported this on 7.3 but it is still there on 7.5.

I was trying to see if using the new constructor and methods for PdfFileStamp might keep from doubling the size of the output file. It didn't. And it also didn't put the stamp on the output file.

I'm including a code snippet to illustrate the constructors and methods involved.

In short, the old constructor throws a compiler warning but still compiles and produces a stamped file.

The new constructor with the BindPdf and Save methods compiles cleanly but produces a file with no stamp on it.

---------------------------------------------------------------------------------------

String strOutputFileName = "output.pdf";
String pdfIn = "input.pdf";

// **** this stamps ** ****
PdfFileStamp stamper = new PdfFileStamp(pdfIn, strOutputFileName);
// **** **** **** **** ****

// **** this does not stamp *****
PdfFileStamp stamper = new PdfFileStamp(); // compiles but does not stamp
stamper.BindPdf(pdfIn);
stamper.Save(strOutputFileName);
// ******************************

String stampLine = "This is the stamp.";
Stamp aStamp = new Stamp();
FormattedText fText = new FormattedText(stampLine, new FontColor(3, 3, 3), Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, false, intFontSizeText);
aStamp.BindLogo(fText);
aStamp.IsBackground = false;
aStamp.Rotation = 0;
aStamp.Opacity = 0.4f;
float x = 100;
float y = 100;
aStamp.SetOrigin(x, y);
stamper.AddStamp(aStamp);
stamper.Close();

Thanks

Steve

Hi Steve,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the details.

I used the following sample code with the latest version of Aspose.Pdf for .NET v7.5 and it works fine with my test file. Please share your template PDF file so we can test the issue.

PdfFileStamp stamper = new PdfFileStamp();

stamper.BindPdf(@"D:\Test.pdf");

String stampLine = "This is the stamp.";

Aspose.Pdf.Facades.Stamp aStamp = new Aspose.Pdf.Facades.Stamp();

FormattedText fText = new FormattedText(stampLine, new FontColor(3, 3, 3), Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, false,14);

aStamp.BindLogo(fText);

aStamp.IsBackground = false;

aStamp.Rotation = 0;

aStamp.Opacity = 0.4f;

float x = 100;

float y = 100;

aStamp.SetOrigin(x, y);

stamper.AddStamp(aStamp);

stamper.Save(@"D:\Test_Stamped.pdf");

stamper.Close();

Sorry for the inconvenience,

Hi Nausherwan,

Thanks for the code snippet. From that I could tell I was putting my 'Save' method in the wrong place in my code. I moved it and now the stamping is working.

However, using the new constructor and methods is producing a very large stamped output file. I will attach an input and output where the output is 4x larger. I have some that are 10x larger. There is an open incident on the old constructor producing output files that are about 2x larger, but these using the new constructor are considerably larger than that.

I am also attaching a Word document with a directory listing of a couple others. The output files are the ones with today's date.

Steve

Hi Steve,


Thanks for sharing the resource files.

I have tested the scenario using input.pdf and I am able to notice that the output PDF file is 2X in size. However in order to resolve this issue, I would suggest you to please try using the following code snippet to reduce/compress the file size. Once the PDF file is stamped, please use the following code.

[C#]

Document doc = new
Document(@“C:\pdftest</span>output.pdf);<o:p></o:p>

doc.OptimizeResources();

doc.Save(@"C:\pdftest\output_Optimized.pdf");

Hi Nayyer,

Yes, I noticed that too (I optimize the input file before stamping and that works well too) but thought that you would want to know about the large output files on un-optimized input files. Optimized or not, the input file shouldn't double (or more) in size upon stamping. Optimizing works fine but it requires another pass through the file and more time consumed.

Thanks

Steve

Hi Steve,


Thanks for sharing the details and sorry for the delayed response.

I
have tested the scenario and I am able to reproduce the same problem that size of input document doubles when processed through
PdfFileStamp. For the
sake of correction, I have logged it in our issue tracking system as
PDFNEWNET-34681. We
will investigate this issue in details and will keep you updated on the status
of a correction.

We
apologize for your inconvenience.
swl:
However, using the new constructor and methods is producing a very large stamped output file. I will attach an input and output where the output is 4x larger. I have some that are 10x larger. There is an open incident on the old constructor producing output files that are about 2x larger, but these using the new constructor are considerably larger than that.

I am also attaching a Word document with a directory listing of a couple others. The output files are the ones with today's date.

Hi Steve,

I have been able to notice the 2X size increase when stamping the PDF file using PdfFileStamp. However can you please share some documents which are producing 10X larger size documents so that we can further investigate this issue. We are really sorry for this inconvenience.

Hi Steve,


Thanks for your patience. We have further investigated the issue PDFNEWNET-34681 and in order to resolve this issue, please try using OptimizeSize property in PdfFileStamp (which will become available with the release of Aspose.Pdf for .NET 7.7.0)
[C#]

PdfFileStamp stamper = new PdfFileStamp();<o:p></o:p>

stamper.OptimizeSize = true;

stamper.BindPdf(TestSettings.GetInputFile("34681.pdf"));

Thanks.

Sounds like a good solution.

Steve

The issues you have found earlier (filed as PDFNEWNET-34681) have been fixed in Aspose.Pdf for .NET 7.7.0.


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