PDFedit Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000343 [Kernel] =Other (Kernel)= major always 11-30-09 11:17 11-30-09 11:55
Reporter hockm0bm View Status public  
Assigned To hockm0bm
Priority high Resolution fixed  
Status resolved  
Summary 0000343: properties returned directly from trailer are not editable
Description The following program which is supposed to change a document author:

boost::shared_ptr<CPdf> pdf = CPdf::getInstance(argv[1], CPdf::ReadWrite);
  boost::shared_ptr<const CDict> trailer = pdf->getTrailer();
  boost::shared_ptr<IProperty> docInfoProp = trailer->getProperty("Info");
  boost::shared_ptr<CDict> docInfo = utils::getCObjectFromRef<CDict>(docInfoProp); // <<<<<<<<<<< FAILS

  std::string newAuthor = "New Author";
  boost::shared_ptr<IProperty> authorProp(CStringFactory::getInstance(newAuthor));
  docInfo->setProperty("Author", *authorProp);

fails with:
change_author: /usr/local/include/pdfedit-0.4.3/kernel/cpdf.h:1877: boost::shared_ptr<X> pdfobjects::utils::getCObjectFromRef(const boost::shared_ptr<pdfobjects::IProperty>&) [with CType = pdfobjects::CDict]: Assertion `hasValidRef(refProp)' failed.
Additional Information
Attached Files  getCObjectFromRef-fix_for_trailers_properties.patch [^] (1,150 bytes) 11-30-09 11:44

- Relationships

- Notes
(0001003)
hockm0bm
11-30-09 11:37

The problem seems to be that getCObjectFromRef checks validity of the refProp::indiRef. This is of course [0,0] because the parent property is the trailer which doesn't have any reference.

I don't see any reason why we need to check for this here, btw. We are using pdf to get the final object and the property value is correct.
 
(0001004)
hockm0bm
11-30-09 11:44

getCObjectFromRef-fix_for_trailers_properties.patch should fix this problem.
 
(0001005)
hockm0bm
11-30-09 11:55

Patch is in the CVS
 

- Issue History
Date Modified Username Field Change
11-30-09 11:17 hockm0bm New Issue
11-30-09 11:17 hockm0bm Status new => assigned
11-30-09 11:17 hockm0bm Assigned To  => hockm0bm
11-30-09 11:37 hockm0bm Note Added: 0001003
11-30-09 11:44 hockm0bm File Added: getCObjectFromRef-fix_for_trailers_properties.patch
11-30-09 11:44 hockm0bm Note Added: 0001004
11-30-09 11:55 hockm0bm Status assigned => resolved
11-30-09 11:55 hockm0bm Resolution open => fixed
11-30-09 11:55 hockm0bm Note Added: 0001005