Some test text!
Portable Document Format (PDF) is the open de-facto standard for electronic document distribution worldwide. PDF is a universal file format that preserves all the fonts, formatting, graphics, and color of any source document, regardless of the application and platform used to create it. PDF files are compact and can be shared, viewed, navigated, and printed exactly as intended.
In many ways, Cos is to PDF what XML is to SVG (Scalable Vector Graphics). Cos object system provides the low-level object types and file structure used in PDF files. PDF documents are graphs of Cos objects. Cos objects can represent document components such as bookmarks, pages, fonts, and annotations, etc.
PDF is not the only document format built on top of Cos. FDF (Form Data Format) and PJTF (Portable Job Ticket Format) are also built on top of Cos.
The Cos layer deals directly with the data that is in a PDF (or Cos based) file. The data types are referred to as Cos Objects. There are eight data types found in PDF files. They are arrays, dictionaries, numbers, Boolean values, names, strings, streams, and a null object. In order to retrieve or modify PDF (or other Cos based) content, you need to understand these objects. You can destroy existing objects, create new objects, or modify the data in objects in PDF files and other Cos based documents.
For a detailed description of Cos layer refer to the Chapter 3 (Syntax) of PDF Reference Manual 1.4 available online.
To create a new document, select 'New' in File menu. The new document will contain only a trailer and info dictionary. You can then add new objects using New Atom/Container from Edit menu or you can import objects from other documents
For more information, see How to import objects from another document?).
Go to 'File/Document Properties'. Edit document meta-information. Click 'OK'. Alternatively, you can directly edit 'Info' dictionary referenced in the trailer object.
Go to 'Edit/Document Security'
The security handler associated with the document is shown in the combo box. It is possible to remove or select a new security handler by selecting a different entry in the combo box.
'Standard Security' and 'No security' are default security handlers installed with CosEdit.
If the document is encrypted, you can either view current security options by clicking on 'View Settings' or you can modify existing settings by selecting 'Change Settings'.
You can limit access to PDF and other Cos based documents by giving the files passwords and restricting certain features such as printing and editing. A document can have an user password and a master (also known as the owner) password. If the file has both passwords, it can be opened with either one. When a file is opened with the user password, the security restrictions are temporarily disabled. If you set any security restrictions in your file, you should also specify a change security setting password (owner or master password); otherwise anyone who opens the file could remove the restrictions.
You can select between the 40-bit and 128-bit RC4. The 128-bit RC4 encryption level has a higher level of security, but is compatible only with PDF 1.4 and higher.
Depending on the selected security level, you can select different permission sets. Permissions associated with a 40-bit security handler are usually a subset of a 128-bit security handler and will be grayed out.
To modify a link (indirect reference) object within a dictionary, drag the object you would like to link from the cross-reference table and drop it on the dictionary view. Application will ask you to enter a dictionary key for the new link. Enter the key name of the link you would like to modify. Click 'OK'. The new key value pair will overwrite the old entry.
Alternatively, 'right' click and select 'New Link' in the object view context menu (Ctrl+K). Then, specify the object number of the link destination.
To modify a link (indirect reference) object within an array, drag the object you would like to link from the cross-reference table and drop it on the link you would like to modify in an array view. The new link should appear just before the old link. Delete the old link using the delete key.
Sometimes it is desirable to modify all indirect references to a given indirect object. It would be very inefficient to manually search and edit all indirect references to a given indirect object.
A more efficient and less error-prone method is to replace the indirect object in the cross-reference table with a new object. This way the object that is referred to is modified (or replaced) and indirect references do not have to be changed.
To replace an indirect object, select the corresponding list entry in the cross-reference table view and then 'right' click to get a context menu. Click on 'Indirect Swap' menu item. You will be prompted to enter the object numbers of the entries you would like to swap. Click 'OK'.
The default stream data viewer is Notepad. Since Notepad is restrictive in many ways, you can choose a different stream viewer. To select a new stream data viewer, select 'Customize' in the 'Options' menu. Then click on 'Choose stream viewer' within the 'Streams' tab. Use the file dialog box to locate the new stream data viewer and then click 'OK' (Open).
Select a stream object. Double click on '- DATA -' filed. Stream data will be extracted to the associated viewer.
Alternatively, you can 'right' click. Select 'Save Stream Data to File' from the object context menu. Then select the filename where you would like to extract the stream.
You can control whether the stream should be decoded by selecting 'Decode Stream' in the 'Options' menu.
If 'Decode Stream' is checked, associated decode filters will be applied.
If 'Decode Stream' is not checked, decode filters will not be applied. However, the stream will be decrypted if the document is encrypted.
The contents of a PDF file can be updated incrementally, without rewriting the entire file. Changes are appended to the end of the file, leaving its original contents intact. The main advantage to updating a file in this way is that it enables small changes to a large document to be saved quickly. For other advantages related to incremental save refer to the PDF Reference Manual.
CosEdit supports incremental save. To activate incremental save click on 'Customize' in the 'Options' menu and make sure that 'Incremental save' is checked within 'Save Options' tab.
By default, all documents saved using the full-save mode will have %PDF-1.4 as a header. You may want to use a different header in order to save the file in an older PDF version or as other document formats such as FDF, PJTF, etc.
To select a new header, select 'Customize' in the 'Options' menu. Then enter the new value within the 'Save Options' tab. Note that any header should start with the comment character, %.
You can copy an object either by dragging it from one document to another, from one document view to another, or by using cut/copy/paste commands from the Edit menu.
You can control the extent of the copy operation using 'Deep Copy' check in the 'Options' menu.
If checked, deep copy is enabled. This means that when an object is copied all objects referenced by that object are also copied. This rule applies to all referenced objects recursively. Therefore all objects referenced directly or indirectly will be copied.
If deep copy is not checked, shallow copy will be performed. This means that only direct sub-objects will be copied, whereas indirect references will be replaced with Null objects.
To copy a page from one PDF to another you need to understand how pages are organized within PDF and how they map to Cos objects. For details refer to PDF Reference Manual 1.4.
Note that high level editing operations using a low-level tool such as CosEdit can be error prone. This example is provided mainly to illustrate certain features of the editor.
A sample procedure to copy a page from document A to document B is as follows (details may vary depending on the underlying document):
Open documents A and B.
Navigate to the page dictionary of the page you would like to copy in document A (e.g. 0/Root/Pages/Kids/0)
Delete /Parent key (we do this because deep copy will copy all referenced objects, but we do not want to copy parent node). Make sure that 'Deep Copy' is checked in Options menu. Navigate one level up (i.e. to 0/Root/Pages/Kids/) and copy the page node 0 (or the node you have just edited).
In the document B navigate to the place where you would like to insert the node (it is a last Kids array in the tree) and then Paste. Alternatively, you can drag the node from document A and drop it at specific position within the Kids array of document B.
Recreate/Parent link in the destination document. For this you need to know the object number of the /Kids array. You can see the object number in the object number column of the cross-reference table view. Double click on the newly created link. Right click and select New Link from the context menu (or press Ctrl+K). In the New Link dialog box enter the object number of the Kids array that is a parent of this node. Click Ok and rename the New_Key into Parent.
Because we modified the number of pages in the tree, we need to increment all Count values starting from Page root node down to the new page node (i.e. we need to increment /Count value in trailer/Root/Pages, trailer/Root/Pages/Kids/0, and trailer/Root/Pages/Kids/0/Kids/0).
Click on 'Save As' and save the file using a different file name (Call Save As instead of Save for back-up purposes).
Close documents A and B. CosEdit will ask you if you would like to save changes to source document A (we deleted the /Parent node in document A before deep copy was performed). Click No.
Related topics: How to import objects from another document?)
Within PDF, document images are usually stored within the XObject dictionary of the Page object.
Since images stored within PDF do not map to any particular image format, in most cases you will want to check 'Decode Streams' in the 'Options' menu and save the image in Raw format. You can then open the raw image in Photoshop or another image-conversion application and specify the width, height, and bits per component as specified in the image dictionary.
Exceptions to this rule are images with DCTDecode filter. For DCTDecode-ed images you can disable 'Decode Streams' in the 'Options' menu and extract image directly to a Jpeg file.
Related Topics: How to extract stream data?
Navigate to the place in the document where you would like to embed the file. 'Right' click and select 'New Container/Stream' in the 'Object View' context menu. A dialog box will pop up where you can either select the file to import or directly enter the content using Quick Edit.
At this point you can specify whether you want to compress the imported data using Flate compression and/or ASCII filter.
Navigate to the page content stream you would like to edit (e.g. trailer/Root/Pages/Kids/2/Kids/0/Kids/1/Contents). Since the stream may be compressed make sure that 'Decode Stream' is checked in the 'Options' menu. Extract the stream data by double-clicking on -DATA- field.
Now you can edit content stream in the text editor of your choice (See, How to select a different stream data viewer?). Save the content stream in a separate file or copy the content to the clipboard.
Navigate one level up (e.g. trailer/Root/Pages/Kids/2/Kids/0/Kids/1/) and delete old Contents entry. Then create a new stream by selecting 'New Container/Stream' in the 'Object View' context menu. In the 'New Stream' enter the name of the saved content stream or paste data from the clipboard into a 'Quick Edit' box. Click 'OK'.
For more information, see How to embed a file within a document?
Finally, rename the new key (i.e. NewKey0) in the page dictionary into Contents.
Note that certain content stream modifications may require additional steps (such as creating new page resource objects etc).
Alternatively, you can import edited content stream as described in How to embed a file within a document?, and then swap the old and new stream using 'Indirect Swap' command from the Edit menu. Yet another way to replace content stream is to drag the new content stream from cross reference view and drop it on page dictionary overwriting old 'Contents' key.
Get the answers you need: Support
Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.
Select a platform to get started with your free trial.
Unlimited usage. No email address required.