mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-27 05:48:20 +01:00
Load trailer dict.
This commit is contained in:
parent
a5468b1b87
commit
516c6b9ace
41
pdfio-file.c
41
pdfio-file.c
@ -453,9 +453,10 @@ static bool // O - `true` on success, `false` on failure
|
|||||||
load_xref(pdfio_file_t *pdf, // I - PDF file
|
load_xref(pdfio_file_t *pdf, // I - PDF file
|
||||||
off_t xref_offset) // I - Offset to xref
|
off_t xref_offset) // I - Offset to xref
|
||||||
{
|
{
|
||||||
bool done = false; // Are we done?
|
bool done = false; // Are we done?
|
||||||
char line[1024], // Line from file
|
char line[1024], // Line from file
|
||||||
*ptr; // Pointer into line
|
*ptr; // Pointer into line
|
||||||
|
_pdfio_value_t trailer; // Trailer dictionary
|
||||||
|
|
||||||
|
|
||||||
while (!done)
|
while (!done)
|
||||||
@ -496,7 +497,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
|
|||||||
// Read this group of objects...
|
// Read this group of objects...
|
||||||
for (; num_objects > 0; num_objects --, number ++)
|
for (; num_objects > 0; num_objects --, number ++)
|
||||||
{
|
{
|
||||||
intmax_t offset; // Offset in file
|
intmax_t offset; // Offset in file
|
||||||
int generation; // Generation number
|
int generation; // Generation number
|
||||||
pdfio_obj_t *obj; // Object
|
pdfio_obj_t *obj; // Object
|
||||||
|
|
||||||
@ -558,8 +559,36 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Read trailer dict...
|
if (!_pdfioValueRead(pdf, &trailer))
|
||||||
done = true;
|
{
|
||||||
|
_pdfioFileError(pdf, "Unable to read trailer dictionary.");
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_pdfioFileError(pdf, "Trailer is not a dictionary.");
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pdf->trailer)
|
||||||
|
{
|
||||||
|
// Save the trailer dictionary and grab the root (catalog) and info
|
||||||
|
// objects...
|
||||||
|
pdf->trailer = trailer.value.dict;
|
||||||
|
|
||||||
|
if ((pdf->root = pdfioDictGetObject(pdf->trailer, "Root")) == NULL)
|
||||||
|
{
|
||||||
|
_pdfioFileError(pdf, "Missing Root object.");
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
pdf->info = pdfioDictGetObject(pdf->trailer, "Info");
|
||||||
|
pdf->encrypt = pdfioDictGetObject(pdf->trailer, "Encrypt");
|
||||||
|
pdf->id_array = pdfioDictGetArray(pdf->trailer, "ID");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((xref_offset = (off_t)pdfioDictGetNumber(pdf->trailer, "Prev")) <= 0)
|
||||||
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (true);
|
return (true);
|
||||||
|
@ -127,6 +127,8 @@ struct _pdfio_file_s // PDF file structure
|
|||||||
pdfio_dict_t *trailer; // Trailer dictionary
|
pdfio_dict_t *trailer; // Trailer dictionary
|
||||||
pdfio_obj_t *root; // Root object/dictionary
|
pdfio_obj_t *root; // Root object/dictionary
|
||||||
pdfio_obj_t *info; // Information object/dictionary
|
pdfio_obj_t *info; // Information object/dictionary
|
||||||
|
pdfio_obj_t *encrypt; // Encryption object/dictionary
|
||||||
|
pdfio_array_t *id_array; // ID array
|
||||||
|
|
||||||
// Allocated data elements
|
// Allocated data elements
|
||||||
size_t num_arrays, // Number of arrays
|
size_t num_arrays, // Number of arrays
|
||||||
|
@ -20,8 +20,19 @@
|
|||||||
273440CD263D727800FBFD63 /* pdfio-page.c in Sources */ = {isa = PBXBuildFile; fileRef = 273440C2263D727800FBFD63 /* pdfio-page.c */; };
|
273440CD263D727800FBFD63 /* pdfio-page.c in Sources */ = {isa = PBXBuildFile; fileRef = 273440C2263D727800FBFD63 /* pdfio-page.c */; };
|
||||||
273440D8263D72E100FBFD63 /* testpdfio.c in Sources */ = {isa = PBXBuildFile; fileRef = 273440D7263D72E100FBFD63 /* testpdfio.c */; };
|
273440D8263D72E100FBFD63 /* testpdfio.c in Sources */ = {isa = PBXBuildFile; fileRef = 273440D7263D72E100FBFD63 /* testpdfio.c */; };
|
||||||
273440E4263DD7EA00FBFD63 /* pdfio-token.c in Sources */ = {isa = PBXBuildFile; fileRef = 273440E3263DD7EA00FBFD63 /* pdfio-token.c */; };
|
273440E4263DD7EA00FBFD63 /* pdfio-token.c in Sources */ = {isa = PBXBuildFile; fileRef = 273440E3263DD7EA00FBFD63 /* pdfio-token.c */; };
|
||||||
|
27ECBD8926419DAB0025312A /* libpdfio.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 273440B0263D6FE200FBFD63 /* libpdfio.a */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
27ECBD8626419DA40025312A /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 273440A8263D6FE200FBFD63 /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = 273440AF263D6FE200FBFD63;
|
||||||
|
remoteInfo = pdfio;
|
||||||
|
};
|
||||||
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
273440D0263D72AE00FBFD63 /* CopyFiles */ = {
|
273440D0263D72AE00FBFD63 /* CopyFiles */ = {
|
||||||
isa = PBXCopyFilesBuildPhase;
|
isa = PBXCopyFilesBuildPhase;
|
||||||
@ -73,6 +84,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
27ECBD8926419DAB0025312A /* libpdfio.a in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -98,6 +110,7 @@
|
|||||||
273440D7263D72E100FBFD63 /* testpdfio.c */,
|
273440D7263D72E100FBFD63 /* testpdfio.c */,
|
||||||
273440D9263D72EF00FBFD63 /* Documentation */,
|
273440D9263D72EF00FBFD63 /* Documentation */,
|
||||||
273440B1263D6FE200FBFD63 /* Products */,
|
273440B1263D6FE200FBFD63 /* Products */,
|
||||||
|
27ECBD8826419DAB0025312A /* Frameworks */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
@ -125,6 +138,13 @@
|
|||||||
name = Documentation;
|
name = Documentation;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
27ECBD8826419DAB0025312A /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXHeadersBuildPhase section */
|
/* Begin PBXHeadersBuildPhase section */
|
||||||
@ -168,6 +188,7 @@
|
|||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
dependencies = (
|
dependencies = (
|
||||||
|
27ECBD8726419DA40025312A /* PBXTargetDependency */,
|
||||||
);
|
);
|
||||||
name = testpdfio;
|
name = testpdfio;
|
||||||
productName = testpdfio;
|
productName = testpdfio;
|
||||||
@ -237,6 +258,14 @@
|
|||||||
};
|
};
|
||||||
/* End PBXSourcesBuildPhase section */
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXTargetDependency section */
|
||||||
|
27ECBD8726419DA40025312A /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = 273440AF263D6FE200FBFD63 /* pdfio */;
|
||||||
|
targetProxy = 27ECBD8626419DA40025312A /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
273440B2263D6FE200FBFD63 /* Debug */ = {
|
273440B2263D6FE200FBFD63 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
|
Loading…
Reference in New Issue
Block a user