mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-08-20 09:57:23 +08:00
skip offsets outside of file bounds
This commit is contained in:
parent
037b79cd5d
commit
4409998de9
@ -1,32 +1,36 @@
|
||||
namespace UglyToad.PdfPig.Tests.Integration
|
||||
{
|
||||
using System.Diagnostics;
|
||||
//using System.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// A class for testing files which are not checked in to source control.
|
||||
/// </summary>
|
||||
public class LocalTests
|
||||
{
|
||||
[Fact]
|
||||
public void Tests()
|
||||
{
|
||||
var file = @"D:\temp\digitalcorpora\0001\0001849.pdf";
|
||||
try
|
||||
{
|
||||
using (var document = PdfDocument.Open(file, new ParsingOptions { UseLenientParsing = false }))
|
||||
{
|
||||
for (var i = 1; i <= document.NumberOfPages; i++)
|
||||
{
|
||||
var page = document.GetPage(i);
|
||||
var text = page.Text;
|
||||
Trace.WriteLine(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidOperationException($"Error parsing: {Path.GetFileName(file)}.", ex);
|
||||
}
|
||||
}
|
||||
//[Fact]
|
||||
//public void Tests()
|
||||
//{
|
||||
// var files = Directory.GetFiles(@"C:\temp\pdfs", "*.pdf");
|
||||
|
||||
// foreach (var file in files)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using (var document = PdfDocument.Open(file, new ParsingOptions { UseLenientParsing = false }))
|
||||
// {
|
||||
// for (var i = 1; i <= document.NumberOfPages; i++)
|
||||
// {
|
||||
// var page = document.GetPage(i);
|
||||
// var text = page.Text;
|
||||
// Trace.WriteLine(text);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// throw new InvalidOperationException($"Error parsing: {Path.GetFileName(file)}.", ex);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,11 @@ internal static class XrefStreamParser
|
||||
ISeekableTokenScanner scanner,
|
||||
ILog log)
|
||||
{
|
||||
if (xrefOffset >= bytes.Length || xrefOffset < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var offsetCorrectionType = XrefOffsetCorrection.None;
|
||||
var offsetCorrection = 0L;
|
||||
|
||||
|
||||
@ -16,6 +16,11 @@ internal static class XrefTableParser
|
||||
ISeekableTokenScanner scanner,
|
||||
ILog log)
|
||||
{
|
||||
if (xrefOffset >= bytes.Length || xrefOffset < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
bytes.Seek(xrefOffset);
|
||||
|
||||
var correctionType = XrefOffsetCorrection.None;
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
{
|
||||
"profiles": {
|
||||
"UglyToad.PdfPig.ConsoleRunner": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "\"C:\\temp\\pdfs\\archive\""
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user