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

Free Support Forum - aspose.com

Getting an error when I try to loop through the pages on a document

Hi, I keep getting this following error, when I try to loop through the pages of document, in order to add a stamp on each page.

The Error:

Inflating error. Please check the following message: incorrect data checkInflating error. Please check the following message: incorrect data check

Callstack:

at ‡..Read(Byte[] , Int32 , Int32 )
at †..(Byte[] , Object[] )
at ‡..()
at ..Ÿ()
at ...ctor(‰ )
at ‡..Ÿ(‰ )
at „.Œ.()
at Aspose.Pdf.Resources..ctor(Object )
at Aspose.Pdf.Page..ctor(‰ )
at Aspose.Pdf.PageCollection..get_Current()
at PedPointService.DocumentToPDFService.TransformFileData(String fileDataPath, String userName) in C:\Work\TFS\Pedpoint\Trunk\Source\PedPointService\DocumentToPDFService.cs:line 226
at PedPointService.DocumentToPDFService.ApplyWatermarkToFile(String filePath, String waterMarkText) in C:\Work\TFS\Pedpoint\Trunk\Source\PedPointService\DocumentToPDFService.cs:line 31 at ‡..Read(Byte[] , Int32 , Int32 )
at †..(Byte[] , Object[] )
at ‡..()
at ..Ÿ()
at ...ctor(‰ )
at ‡..Ÿ(‰ )
at „.Œ.()
at Aspose.Pdf.Resources..ctor(Object )
at Aspose.Pdf.Page..ctor(‰ )
at Aspose.Pdf.PageCollection..get_Current()
at PedPointService.DocumentToPDFService.TransformFileData(String fileDataPath, String userName) in C:\Work\TFS\Pedpoint\Trunk\Source\PedPointService\DocumentToPDFService.cs:line 226
at PedPointService.DocumentToPDFService.ApplyWatermarkToFile(String filePath, String waterMarkText) in C:\Work\TFS\Pedpoint\Trunk\Source\PedPointService\DocumentToPDFService.cs:line 31

The code i am using:

    Aspose.Pdf.Document pdfdoc = new Aspose.Pdf.Document(fileDataPath);
<span style="color: blue;">string</span> nowDate = System.<span style="color: rgb(43, 145, 175);">DateTime</span>.Now.ToString();
<span style="color: blue;">string</span> watermarkText = <span style="color: blue;">string</span>.Format(<span style="color: rgb(163, 21, 21);">"{0} {1}"</span>, userName, nowDate);

<span style="color: green;">//create text stamp</span>
Aspose.Pdf.<span style="color: rgb(43, 145, 175);">TextStamp</span> textStamp = <span style="color: blue;">new</span> Aspose.Pdf.<span style="color: rgb(43, 145, 175);">TextStamp</span>(watermarkText);

<span style="color: green;">//set whether stamp is background</span>
textStamp.Background = <span style="color: blue;">true</span>;

<span style="color: green;">//set origin</span>
textStamp.XIndent = 100;
textStamp.YIndent = 100;

<span style="color: green;">//rotate stamp</span>
textStamp.Rotate = Aspose.Pdf.<span style="color: rgb(43, 145, 175);">Rotation</span>.on90;

<span style="color: green;">//set text properties</span>
textStamp.TextState.Font = Aspose.Pdf.Text.<span style="color: rgb(43, 145, 175);">FontRepository</span>.FindFont(<span style="color: rgb(163, 21, 21);">"Arial"</span>);
textStamp.TextState.FontSize = 14.0F;
textStamp.TextState.FontStyle = Aspose.Pdf.Text.<span style="color: rgb(43, 145, 175);">FontStyles</span>.Bold;
textStamp.TextState.FontStyle = Aspose.Pdf.Text.<span style="color: rgb(43, 145, 175);">FontStyles</span>.Italic;
textStamp.TextState.ForegroundColor = System.Drawing.<span style="color: rgb(43, 145, 175);">Color</span>.Red;

<span style="color: blue;">foreach</span> (Aspose.Pdf.<span style="color: rgb(43, 145, 175);">Page</span> page <span style="color: blue;">in</span> pdfdoc.Pages)
{
    page.AddStamp(textStamp);
}
    Aspose.Pdf.Document pdfdoc = new Aspose.Pdf.Document(fileDataPath);
 
    string nowDate = System.DateTime.Now.ToString();
    string watermarkText = string.Format("{0} {1}", userName, nowDate);
 
    //create text stamp
    Aspose.Pdf.TextStamp textStamp = new Aspose.Pdf.TextStamp(watermarkText);
 
    //set whether stamp is background
    textStamp.Background = true;
 
    //set origin
    textStamp.XIndent = 100;
    textStamp.YIndent = 100;
 
    //rotate stamp
    textStamp.Rotate = Aspose.Pdf.Rotation.on90;
 
    //set text properties
    textStamp.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Arial");
    textStamp.TextState.FontSize = 14.0F;
    textStamp.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold;
    textStamp.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Italic;
    textStamp.TextState.ForegroundColor = System.Drawing.Color.Red;
 
    foreach (Aspose.Pdf.Page page in pdfdoc.Pages)
    {
        page.AddStamp(textStamp);
    }
I get the error as I enter the foreach loop. I have also tried validating the document, 
by using pdfdoc.Validate(..., but I get the same error.
 
My setup:
MS Visual Studio 2010
Aspose.Pdf version 6.1
The source pdf file is version 1.4. (Attached)
 
Do you have a workaround for this issue?
Best Regards
Dennis Tycho Nielsen
 

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

Thank you for considering Aspose.Pdf for .NET.

We have found your mentioned issue using your shared code and template file after an initial test. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-30066. We will update you through this forum thread once the issue is resolved.

Sorry for the inconvenience caused.

Best Regards,

How can I see the status of the Issue you have created? When can I expect a solution to the issue?


Best Regards

Dennis Tycho Nielsen

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

You can check the status of your issue against the first post in this thread in the left pane against the issue 30066. Also, to update you regarding your issue, our development team has updated the status of your issue and it has been resolved and the update will be a part of our next official release. Please be patient and you will be notified through this forum thread once the new product version is released after testing for the users.

Thank You & Best Regards,

Hi Dennis,

Thanks for your patience.

I am pleased to share that the issue reported earlier has been fixed and its hotfix will be included in upcoming release version 6.2.0. The version is under testing and we expect to release it in few days. Please be patient and spare us little time. Your patience and comprehension is greatly appreciated in this regard.

Thanks,


I am looking forward to it.

And thanks again for your quick handling of this issue.

Best Regards

Dennis Tycho Nielsen

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


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