本文整理匯總了C#中iTextSharp.text.pdf.PdfReader.IsRebuilt方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfReader.IsRebuilt方法的具體用法?C# PdfReader.IsRebuilt怎麽用?C# PdfReader.IsRebuilt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfReader
的用法示例。
在下文中一共展示了PdfReader.IsRebuilt方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Inspect
// ---------------------------------------------------------------------------
/**
* Inspect a PDF file and write the info to a txt file
* @param writer StringBuilder
* @param pdf PDF file bytes
* @param fileName PDF filename
*/
public static void Inspect(StringBuilder sb, byte[] pdf, string fileName)
{
PdfReader reader = new PdfReader(pdf);
sb.Append(fileName);
sb.Append(Environment.NewLine);
sb.Append("Number of pages: ");
sb.Append(reader.NumberOfPages);
sb.Append(Environment.NewLine);
Rectangle mediabox = reader.GetPageSize(1);
sb.Append("Size of page 1: [");
sb.Append(mediabox.Left);
sb.Append(',');
sb.Append(mediabox.Bottom);
sb.Append(',');
sb.Append(mediabox.Right);
sb.Append(',');
sb.Append(mediabox.Top);
sb.Append("]");
sb.Append(Environment.NewLine);
sb.Append("Rotation of page 1: ");
sb.Append(reader.GetPageRotation(1));
sb.Append(Environment.NewLine);
sb.Append("Page size with rotation of page 1: ");
sb.Append(reader.GetPageSizeWithRotation(1));
sb.Append(Environment.NewLine);
sb.Append("Is rebuilt? ");
sb.Append(reader.IsRebuilt().ToString());
sb.Append(Environment.NewLine);
sb.Append("Is encrypted? ");
sb.Append(reader.IsEncrypted().ToString());
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
}
示例2: Test_ReadPdf_01
public static void Test_ReadPdf_01(string file)
{
PdfReader reader = null;
try
{
reader = new PdfReader(file);
Trace.WriteLine("read pdf : \"{0}\"", file);
Trace.WriteLine("number of pages : {0}", reader.NumberOfPages);
Rectangle mediabox = reader.GetPageSize(1);
Trace.WriteLine("size of page 1 : [ {0}, {1}, {2}, {3} ]", mediabox.Left, mediabox.Bottom, mediabox.Right, mediabox.Top);
Trace.WriteLine("rotation of page 1 : {0}", reader.GetPageRotation(1));
Trace.WriteLine("page size with rotation of page 1 : {0}", reader.GetPageSizeWithRotation(1));
Trace.WriteLine("file length : {0}", reader.FileLength);
Trace.WriteLine("is rebuilt ? : {0}", reader.IsRebuilt());
Trace.WriteLine("is encrypted ? : {0}", reader.IsEncrypted());
}
finally
{
if (reader != null)
reader.Close();
}
}
示例3: PdfStamperImp
/** Creates new PdfStamperImp.
* @param reader the read PDF
* @param os the output destination
* @param pdfVersion the new pdf version or '\0' to keep the same version as the original
* document
* @param append
* @throws DocumentException on error
* @throws IOException
*/
internal protected PdfStamperImp(PdfReader reader, Stream os, char pdfVersion, bool append) : base(new PdfDocument(), os) {
if (!reader.IsOpenedWithFullPermissions)
throw new BadPasswordException(MessageLocalization.GetComposedMessage("pdfreader.not.opened.with.owner.password"));
if (reader.Tampered)
throw new DocumentException(MessageLocalization.GetComposedMessage("the.original.document.was.reused.read.it.again.from.file"));
reader.Tampered = true;
this.reader = reader;
file = reader.SafeFile;
this.append = append;
if (reader.IsEncrypted() && (append || PdfReader.unethicalreading)) {
crypto = new PdfEncryption(reader.Decrypt);
}
if (append) {
if (reader.IsRebuilt())
throw new DocumentException(MessageLocalization.GetComposedMessage("append.mode.requires.a.document.without.errors.even.if.recovery.was.possible"));
pdf_version.SetAppendmode(true);
if (pdfVersion == 0) {
pdf_version.PdfVersion = reader.PdfVersion;
}
else {
pdf_version.PdfVersion = pdfVersion;
}
byte[] buf = new byte[8192];
int n;
while ((n = file.Read(buf)) > 0)
this.os.Write(buf, 0, n);
prevxref = reader.LastXref;
reader.Appendable = true;
}
else {
if (pdfVersion == 0)
base.PdfVersion = reader.PdfVersion;
else
base.PdfVersion = pdfVersion;
}
if (reader.IsTagged()) {
this.SetTagged();
}
base.Open();
pdf.AddWriter(this);
if (append) {
body.Refnum = reader.XrefSize;
marked = new IntHashtable();
if (reader.IsNewXrefType())
fullCompression = true;
if (reader.IsHybridXref())
fullCompression = false;
}
initialXrefSize = reader.XrefSize;
ReadColorProfile();
}
示例4: PdfStamperImp
/** Creates new PdfStamperImp.
* @param reader the read PDF
* @param os the output destination
* @param pdfVersion the new pdf version or '\0' to keep the same version as the original
* document
* @param append
* @throws DocumentException on error
* @throws IOException
*/
internal PdfStamperImp(PdfReader reader, Stream os, char pdfVersion, bool append)
: base(new PdfDocument(), os)
{
if (reader.Tampered)
throw new DocumentException("The original document was reused. Read it again from file.");
reader.Tampered = true;
this.reader = reader;
file = reader.SafeFile;
this.append = append;
if (append) {
if (reader.IsRebuilt())
throw new DocumentException("Append mode requires a document without errors even if recovery was possible.");
if (reader.IsEncrypted())
crypto = new PdfEncryption(reader.Decrypt);
pdf_version.SetAppendmode(true);
file.ReOpen();
byte[] buf = new byte[8192];
int n;
while ((n = file.Read(buf)) > 0)
this.os.Write(buf, 0, n);
file.Close();
prevxref = reader.LastXref;
reader.Appendable = true;
}
else {
if (pdfVersion == 0)
base.PdfVersion = reader.PdfVersion;
else
base.PdfVersion = pdfVersion;
}
base.Open();
pdf.AddWriter(this);
if (append) {
body.Refnum = reader.XrefSize;
marked = new IntHashtable();
if (reader.IsNewXrefType())
fullCompression = true;
if (reader.IsHybridXref())
fullCompression = false;
}
initialXrefSize = reader.XrefSize;
}
示例5: RetrieveBasicProperties
/// <summary>
/// Retrieves the following properties as <see cref="Dictionary<String,String>"/> key/value pairs:
/// Page Count, Encrypted, Pdf Version, Rebuilt
/// </summary>
/// <param name="filename">The PDF file</param>
/// <returns>A <see cref="Dictionary<String, String>"/> object</returns>
/// <exception cref="ArgumentNullException"></exception>
/// <remarks></remarks>
public Dictionary<String, String> RetrieveBasicProperties(String filename)
{
Dictionary<String, String> basicProperties = new Dictionary<string, string>();
if (!String.IsNullOrEmpty(filename) && !String.IsNullOrWhiteSpace(filename))
{
var documentReader = new iTextSharpPDF.PdfReader(new iTextSharpPDF.RandomAccessFileOrArray(filename), null);
basicProperties.Add("Page Count", documentReader.NumberOfPages.ToString());
basicProperties.Add("Encrypted", documentReader.IsEncrypted().ToString());
basicProperties.Add("Pdf Version", documentReader.PdfVersion.ToString());
basicProperties.Add("Rebuilt", documentReader.IsRebuilt().ToString());
documentReader.Close();
}
else
{
throw new ArgumentNullException("filename", exceptionArgumentNullOrEmptyString);
}
return basicProperties;
}