Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Issue with convert pdf

$
0
0
Hi,

I am trying to convert a 5M word file to a protected pdf file.

1.I convert the word file to a temp.pdf with Aspose.word successfully.
2.I would convert the temp.pdf to a prtected pdf file. I use the following codes.

Document wordFile = new Document(stcPath);
wordFile.Save("temp.pdf", potions);

Document tempPdf = new Aspose.Pdf.Document("temp.pdf");
for (int pageCount = 1; pageCount <= tempPdf.Pages.Count; pageCount++)
{
using (FileStream imageStream = FileStream(tempfile, FileMode.Create))
{
Rectangle rect = tempPdf.Pages[pageCount].Rect;
jpegDevice.Process(tempPdf.Pages[pageCount], imageStrem);
tempPdf.Pages.Delete(pageCount);
tempPdf.Pages.Insert(pageCount);
Page page = tempPdf.Pages[pageCount];
page.Rect = rect;
double upperRightX = rect.Width;
double upperRightY = rect.Height;
page.Resources.Images.Add(imageStream);
page.Contents.Add(new Operator.GSave());
Rectangle rectangle = new Rectangle(0.0, 0.0, upperRightX, upperRightY);
Matrix matrix = new Matrix(new double[] {rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY});
page.Contents.Add(new Operator.ConcatenateMatrix(matrix));
XImage ximage = page.Resources.Images[page.Resources.Images.Count];
page.Contents.Add(new Operator.Do(ximage.Name));
imageStream.Close();
}
}
tempPdf.Encrypt(string.Empty, string.Empty, 0, CryptoAlgorithm.RC4x128);
rwmpPdf.Save(pdfPath);

Issue: I catch a exception: Encryprion of huge stream is not implemented.

Now, I am trying to upgrade Aspose to the latest version. My license dosen't support the latest version. I would make sure Aspose of the latest version can work successfully. Then I will buy a new license.

When I use new version with my old license, I catch a new exception:"indexOutOfRangeException" with the same code.

tempPdf.Pages.Count = 14;
pageCount = 5;
Rectangle rect = tempPdf.Pages[pageCount].Rect; // here catch the exception

My OS is Windows Vista Business Service Pack 2 architecture 32-bit, Memory is 2G. Test file please see attachment.

I want to know:
1.How to fix my first problem. 
2. what cause the second problem.

Thanks!

Chen


Viewing all articles
Browse latest Browse all 3131

Trending Articles