0

旋转页面时,不应将其转换为删除 pdf 文档中搜索的图像。

using WebSupergoo.ABCpdf9;
Doc doc = new Doc();
byte[] source = // some source of pdf byte array
doc.Read(source);
for (int i = 1; i <= doc.PageCount; i++)
{
     doc.PageNumber = i;
     double w = doc.MediaBox.Width;
     double h = doc.MediaBox.Height;
     double l = doc.MediaBox.Left;
     double b = doc.MediaBox.Bottom;
     doc.Transform.Rotate(90, l, b);
     doc.Transform.Translate(w, 0);

     // rotate our rectangle
     doc.Rect.Width = h;
     doc.Rect.Height = w;
}
MemoryStream stream = new MemoryStream();
doc.Save(stream); 

上面的代码似乎不起作用。请适当建议。

4

1 回答 1

3

我尝试使用 itextsharp 库来实现这一点。

            byte[] source = // some source of pdf byte array
            MemoryStream outStream = new MemoryStream();
            PdfReader reader = new PdfReader(scannedInvoice.imgImage);
            PdfStamper stamper = new PdfStamper(reader, outStream);

            for (int i = 1; i <= reader.NumberOfPages; i++)
            {
                PdfDictionary pageDict = reader.GetPageN(i);
                int desiredRot = 90; // 90 degrees clockwise
                PdfNumber rotation = pageDict.GetAsNumber(PdfName.ROTATE);
                if (rotation != null)
                {
                    desiredRot += rotation.IntValue;
                    desiredRot %= 360; // 0, 90, 180, 270
                }
                pageDict.Put(PdfName.ROTATE, new PdfNumber(desiredRot));
            }
            stamper.Close();
            var rotatedpdfArray = outStream.ToArray(); // The rotated output

希望这可以帮助.......

于 2015-07-16T10:29:09.387 回答