Skip to main content

Lesson 2: Getting the text right

A check is only as good as the text it reads. In this lesson you make Extracts read exactly the value, not the label next to it or the line below it. You set up a whole row of title block fields in one go, build the drawing number from the seven small boxes of the title block, and check it against the file name.

What you learn​

  • How text is stored in a PDF, and why NodePDF joins it without spaces.
  • The extract modes Overlap and Contain, and the Reading order.
  • The Modifiers Remove text, Replace text and Keep the first / last N characters.
  • How to set up many fields at once with Auto-extract title block, and adjust them in the canvas editor.
  • The File name and Combination Extracts, and the Matches filename Validator.
  • Why an area that works on an A3 sheet can read nothing on an A1 sheet.

Files for this lesson​

Download Lesson 2 files (zip) and unpack it.

FileWhat it is for
template/NDXTEST-NHX-B1-00-DR-A-200100_P02_A3_landscape.pdfThe template for the document type.
check/NDXTEST-NHX-B1-01-DR-A-200101_P02_A3_landscape.pdfA3 drawing to check.
check/NDXTEST-NHX-B1-00-DR-A-200102_P02_A1_landscape.pdfAn A1 sheet of the same project, with the same title block.
check/NDXTEST-NHX-B1-RF-DR-A-200103_P02_A3_landscape.pdfA3 drawing to check.
check/NDXTEST-NHX-B1-ZZ-DR-A-200104_P01_A3_landscape.pdfA3 drawing to check.

How NodePDF reads text​

Text items​

A PDF does not store sentences. It stores text items: pieces of text, each with its position on the page. A box of the title block usually holds two items, the small grey label and the value:

  • "CLIENT" (the label)
  • "EXAMPLE CLIENT" (the value)

An Extract takes every text item in its area and joins them without spaces. The CLIENT area therefore reads CLIENTEXAMPLE CLIENT, and the two-line PROJECT box reads PROJECTEXAMPLE PROJECTBUILDING 1 – CAT A OFFICE & WORKSPACE. Modifiers then turn this into the value you want to check.

Extract mode: Overlap or Contain​

The Extract mode decides which text items an area takes. Overlap, the default, takes every item that lies at least 75 % inside the area, and Contain takes only items that lie completely inside it, which keeps out a neighbouring text that reaches into the area. See Extracts › Extract modes.

Overlap and Contain on two cases. A value that runs past the edge of its cell, 89 % inside the area: Overlap reads it whole, Contain reads nothing. A small neighbouring REV value 82 % inside the area: Overlap reads it with the drawing number, NDX-A-200100P02, Contain reads only NDX-A-200100

Reading order​

The Reading order decides the order in which the items are joined. As in the PDF is right for most title blocks, and Top to bottom priority helps when a value made of several pieces comes out in the wrong order. See Extracts › Reading orders.

The three reading orders on a two-line drawing title whose items are stored as BUILDING 1, PLAN, GROUND FLOOR. As in the PDF reads BUILDING 1PLANGROUND FLOOR, Top to bottom priority reads GROUND FLOORPLANBUILDING 1, Left to right priority reads GROUND FLOORBUILDING 1PLAN

Modifiers​

A Modifier changes the text before it is checked, and several can be chained, applying in order. There are four: Remove text, Replace text, Keep the first N characters and Keep the last N characters (called Keep the first characters and Keep the last characters in the Add menu). Remove text and Replace text match upper and lower case exactly. See Modifiers.

File name and Combination​

Two Extracts do not read an area of the page:

  • File name reads the PDF's file name, including .pdf.
  • Combination joins the text of other Extracts or Modifiers with a pattern. Each source gets a letter, a, b, c and so on, in order. The pattern a-b puts the text of the first source, a hyphen, and the text of the second source.
warning

A Combination replaces the first a, b, c… in the pattern, and the pattern is turned into lower case. Put the letters of the sources first, before any fixed text that contains those letters. For example, a_b_c_landscape works: the first "a" and the first "c" are the placeholders, and the "a" and "c" inside "landscape" are left alone. See Documentation › Extracts › Combination quirks.

The Matches filename Validator passes when its text equals the PDF's file name. A lower-case .pdf is ignored on both sides, and upper and lower case matter.

Steps​

Set up the project​

  1. Create a new project named Lesson 2, drop the lesson 2 template on the Doctypes tab, open the new document type and rename it to Drawing with Edit details (as in lesson 1).

Set up the title block fields in one go​

  1. In the Items section, choose Auto-extract title block. The popup finds every box of the title block and lists it as a field, titled after its label. On these drawings it finds 38 boxes, including the revision table and the notes.

    The Auto-extract title block popup, with the fields found on the template

  2. Choose Remove all. Then click these boxes on the title block picture, one after the other: CLIENT, PROJECT, REVISION, SIZE, and the seven small boxes of the drawing number: Project, Originator, Volume, Level, Type, Role and Number. Use Ctrl + scroll to zoom in.

  3. Rename the title of the small Project box to Project code, so that it is not confused with the PROJECT box.

  4. Check the Reads column. Each field reads its value without the label: CLIENT reads EXAMPLE CLIENT, REVISION reads P02, SIZE reads A3, Number reads 200100.

  5. In the CLIENT row, choose the + in the Fixed value column. A check Exactly "EXAMPLE CLIENT" is added. Add no checks to the other rows yet.

  6. Choose Add 11 fields.

The Items section now lists 11 field validations. Each has a PDF area and a Remove text Modifier for its label. The ones without a check are marked Not checked: NodePDF reads them but checks nothing. Lesson 3 is about removing those markers.

A field validation expanded: PDF area, then Remove text, then the Fixed value check

Click the chevron in front of a row to expand it. The blocks show what each step reads and gives: the PDF area reads CLIENTEXAMPLE CLIENT, Remove text gives EXAMPLE CLIENT. Click a block to edit it.

Fix the two-line PROJECT box​

  1. Expand the PROJECT row. Its Remove text block gives EXAMPLE PROJECTBUILDING 1 – CAT A OFFICE & WORKSPACE: both lines of the box, joined without a space.
  2. Choose Edit on template. The guided setup opens at step 2, Check the value.
  3. Choose Keep the first N characters, enter 15, and confirm. The value becomes EXAMPLE PROJECT. The list Changes, in the order they apply now shows Remove "PROJECT" and then the new change.
  4. Choose Yes, check this value, then Exactly "EXAMPLE PROJECT", then Done.

You could also check the whole text with a Fixed value, but then you would have to type the dash "–" exactly as the drawing has it. Keeping the first 15 characters is simpler and checks the part that matters.

  1. Click the PDF area block of the PROJECT row. Its editor shows the Extract mode and the Reading order. Switch the reading order to Top to bottom priority and back to As in the PDF: on this box both give the same result, because the PDF already stores the first line first. Choose Cancel.

Adjust areas in the canvas editor​

  1. Choose Open canvas editor at the top of the document type page. The canvas editor shows every field on the template. With Select (V), click a field to select it, drag its corners to change the area, and hover a text inside it: − removes that text from the value, + uses it as the title.

    The canvas editor with the CLIENT field selected

  2. Go back with the arrow at the top left. You do not need to change anything.

Build the drawing number from the seven boxes​

  1. In the Items section, choose Add › Extract: Combination.

  2. Type Drawing number as the Name (optional).

  3. Choose Add source seven times and set the sources a to g to: Project code, Originator, Volume, Level, Type, Role, Number.

    Each field appears twice in the source list under the same name: once for its PDF area (with the label) and once for its Remove text Modifier (without the label). Pick the entries that give the values without labels. The preview below the pattern tells you: it must not contain words like "Originator" or "Role".

  4. Type a-b-c-d-e-f-g as the Pattern. The preview reads NDXTEST-NHX-B1-00-DR-A-200100.

  5. Choose Save.

Check it against the file name​

The file names of these drawings are the drawing number, the revision, the sheet size and the orientation, for example NDXTEST-NHX-B1-00-DR-A-200100_P02_A3_landscape.pdf. To compare, build the same text from the title block.

  1. Choose Add › Extract: Combination again. Name it File name check.
  2. Add three sources: a = Drawing number, b = REVISION (the entry without the label), c = SIZE (the entry without the label).
  3. Type a_b_c_landscape as the Pattern. The preview reads NDXTEST-NHX-B1-00-DR-A-200100_P02_A3_landscape. Choose Save.
  4. Choose Add › Validator: Matches filename. In Checks, pick File name check, and choose Save. Its On template result is Passes.

Run the report​

  1. On the Validate tab, choose the four PDFs from the check folder, name the report Lesson 2, and choose Run report.
  2. Export the report to Excel and filter the Results sheet on Status FAIL.

The A1 sheet​

One of the four drawings is an A1 sheet. Its title block has the same size in millimetres as on the A3 sheets, so on the much larger A1 page it covers a smaller part of the page, further to the right and lower down. Your areas are stored as page fractions of the A3 template, so on the A1 sheet they land on empty paper above the title block. The checks read nothing and fail with "The extract is empty".

Areas versus a data frame: an area drawn on the A3 template lands on blank paper on an A1 sheet, while a data frame is found by its anchors wherever the title block sits

This is not a fault in the drawing. It is the limit of areas drawn on a template. Two ways around it:

  • a data frame: a title block that NodePDF looks for on the page by its labels, wherever it sits and at any sheet size. One document type then checks every sheet size. That is lesson 6, and it is the way to go.
  • a separate document type with its own template, only when the sheets really have a different title block, not just a different size (lesson 5 shows how to send each PDF to the right document type).

Open the A1 drawing in the Review view to see where the areas landed.

Exercise​

Set up the document type as in the steps: CLIENT (Exactly "EXAMPLE CLIENT"), PROJECT (Keep the first 15 characters, then Exactly "EXAMPLE PROJECT"), the Combinations "Drawing number" and "File name check", and a Matches filename check on "File name check". Run it on the four drawings in the check folder.

You're done when…

  • every check shows Passes on the template;
  • the report shows Files 4, and Results 4: 2 passed, 2 failed;
  • drawings 200101 and 200104 pass;
  • drawing 200103 fails only the Matches filename check: the title block says revision P01, but the file name says P02 (Details: File name is "NDXTEST-NHX-B1-RF-DR-A-200103_P02_A3_landscape.pdf");
  • the A1 drawing 200102 fails, with CLIENT and PROJECT reading nothing ("The extract is empty"), and you can explain why.
In the example project

In NDX Example - Text and drawings, document type Drawing, the PROJECT field of the data frame "Title block" checks the whole two-line text with a Fixed value. Compare it with your Keep the first 15 characters approach. The Excel export of the example report shows the joined text in the Extracted Text column.

Check yourself​

An area reads "SCALE1:200 @ A3". Which Modifier gives "1:200 @ A3"?
A neighbouring text reaches a little into your area and ends up in the value. What can you change?
Why does the pattern a_b_c_landscape not replace the "a" in "landscape"?
The checks work on every A3 drawing but read nothing on an A1 sheet of the same project. Why?

See also​