Skip to main content
deleted 2 characters in body; edited title
Source Link
Lou
  • 4.1k
  • 23
  • 28

Importing PDF with Mathematica 12.2 on Windows skips newlines

I'm using Windows 10 with MM12.2 PDF with MM 12.2 import does not include the standalone newlines anymore. This is a very annoying issue since we would like to extract paragraphs which is now not possible. We tried other PDF import methods: PDF2TEXT which successfully keeps the additional newlines when importing the .txt file as TXT. Export using Acrobat reader with "Save as text file". When importing the file as a text file the additional newlines are present.

We need to import thousands of PDF files and the new PDF import that came with version 12.2 is accepting a lot more PDF's than before but deletes the newlines the mark paragraphs. In fact TextCases relies on the "return/newlines" code to detect paragraphs (see:https://reference.wolfram.com/language/ref/textcontent/Paragraph.html) so combined with the new PDF importer doesn't really makes it useful.

Are there any known options to not delete the additional newlines?

An easy example is created below.

teststring = "sentence 1\nsentence 2\n\nsentence 3\n\n\nsentence 4" 
(*Create a string with additional newlines*)
Export["newlinepdf.pdf", teststring] (*export to PDF*)
wrongstring=Import["newlinepdf.pdf", "Plaintext"] (*Import again and notice that the additional newlines are missing. This behaviour is consistent with all PDF's we tried*)
Import["newlinepdf.pdf", "PlaintextLegacy"] (*The leagcy undocumented option works (but doubles the newlines)for this example but fails with other PDF's we tried (errors out)*)

Subscript[#, ToString@First@ToCharacterCode[#]] & /@ (teststring // Characters)

the teststring with charactercodes looks like this enter image description here

Subscript[#, ToString@First@ToCharacterCode[#]] & /@ (wrongstr // Characters)

The imported version with "Plaintext" option

enter image description here

Importing PDF skips newlines

I'm using Windows 10 with MM12.2 PDF with MM 12.2 import does not include the newlines anymore. This is a very annoying issue since we would like to extract paragraphs which is now not possible. We tried other PDF import methods: PDF2TEXT which successfully keeps the additional newlines when importing the .txt file as TXT. Export using Acrobat reader with "Save as text file". When importing the file as a text file the additional newlines are present.

We need to import thousands of PDF files and the new PDF import that came with version 12.2 is accepting a lot more PDF's than before but deletes the newlines the mark paragraphs. In fact TextCases relies on the "return/newlines" code to detect paragraphs (see:https://reference.wolfram.com/language/ref/textcontent/Paragraph.html) so combined with the new PDF importer doesn't really makes it useful.

Are there any known options to not delete the additional newlines?

An easy example is created below.

teststring = "sentence 1\nsentence 2\n\nsentence 3\n\n\nsentence 4" 
(*Create a string with additional newlines*)
Export["newlinepdf.pdf", teststring] (*export to PDF*)
wrongstring=Import["newlinepdf.pdf", "Plaintext"] (*Import again and notice that the additional newlines are missing. This behaviour is consistent with all PDF's we tried*)
Import["newlinepdf.pdf", "PlaintextLegacy"] (*The leagcy undocumented option works (but doubles the newlines)for this example but fails with other PDF's we tried (errors out)*)

Subscript[#, ToString@First@ToCharacterCode[#]] & /@ (teststring // Characters)

the teststring with charactercodes looks like this enter image description here

Subscript[#, ToString@First@ToCharacterCode[#]] & /@ (wrongstr // Characters)

The imported version with "Plaintext" option

enter image description here

Importing PDF with Mathematica 12.2 on Windows skips newlines

I'm using Windows 10 with MM12.2 PDF import does not include the standalone newlines anymore. This is a very annoying issue since we would like to extract paragraphs which is now not possible. We tried other PDF import methods: PDF2TEXT which successfully keeps the additional newlines when importing the .txt file as TXT. Export using Acrobat reader with "Save as text file". When importing the file as a text file the additional newlines are present.

We need to import thousands of PDF files and the new PDF import that came with version 12.2 is accepting a lot more PDF's than before but deletes the newlines the mark paragraphs. In fact TextCases relies on the "return/newlines" code to detect paragraphs (see:https://reference.wolfram.com/language/ref/textcontent/Paragraph.html) so combined with the new PDF importer doesn't really makes it useful.

Are there any known options to not delete the additional newlines?

An easy example is created below.

teststring = "sentence 1\nsentence 2\n\nsentence 3\n\n\nsentence 4" 
(*Create a string with additional newlines*)
Export["newlinepdf.pdf", teststring] (*export to PDF*)
wrongstring=Import["newlinepdf.pdf", "Plaintext"] (*Import again and notice that the additional newlines are missing. This behaviour is consistent with all PDF's we tried*)
Import["newlinepdf.pdf", "PlaintextLegacy"] (*The leagcy undocumented option works (but doubles the newlines)for this example but fails with other PDF's we tried (errors out)*)

Subscript[#, ToString@First@ToCharacterCode[#]] & /@ (teststring // Characters)

the teststring with charactercodes looks like this enter image description here

Subscript[#, ToString@First@ToCharacterCode[#]] & /@ (wrongstr // Characters)

The imported version with "Plaintext" option

enter image description here

added 658 characters in body
Source Link
Lou
  • 4.1k
  • 23
  • 28

PDFI'm using Windows 10 with MM12.2 PDF with MM 12.2 import does not include the newlines anymore. This is a very annoying issue since we would like to extract paragraphs which is now not possible. We tried other PDF import methods: PDF2TEXT which successfully keeps the additional newlines when importing the .txt file as TXT. Export using Acrobat reader with "Save as text file". When importing the file as a text file the additional newlines are present.

We need to import thousands of PDF files and the new PDF import that came with version 12.2 is accepting a lot more PDF's than before but deletes the newlines the mark paragraphs. In fact TextCases relies on the "return/newlines" code to detect paragraphs (see:https://reference.wolfram.com/language/ref/textcontent/Paragraph.html) Areso combined with the new PDF importer doesn't really makes it useful.

Are there any known options to not delete the additional newlines?

An easy example is created below.

teststring = "sentence1\nsentence2\n\nsentence3\n\n\nsentence4""sentence 1\nsentence 2\n\nsentence 3\n\n\nsentence 4" 
(*Create a string with additional newlines*)
Export["newlinepdf.pdf", teststring] (*export to PDF*)
Import["newlinepdfwrongstring=Import["newlinepdf.pdf", "Plaintext"] (*Import again and notice that the additional newlines are missing. This behaviour is consistent with all PDF's we tried*)
Import["newlinepdf.pdf", "PlaintextLegacy"] (*The leagcy undocumented option works (but doubles the newlines)for this example but fails with other PDF's we tried (errors out)*) 

Subscript[#, ToString@First@ToCharacterCode[#]] & /@ (teststring // Characters)

the test string prints out as

sentence1teststring with charactercodes looks like this sentence2

sentence3enter image description here

sentence4

Subscript[#, ToString@First@ToCharacterCode[#]] & /@ (wrongstr // Characters)

The Import givesimported version with "Plaintext" option

sentence1 sentence2 sentence3 sentence4enter image description here

PDF with MM 12.2 import does not include the newlines anymore. This is a very annoying issue since we would like to extract paragraphs which is now not possible. We tried other PDF import methods: PDF2TEXT which successfully keeps the additional newlines when importing the .txt file as TXT. Export using Acrobat reader with "Save as text file". When importing the file as a text file the additional newlines are present.

We need to import thousands of PDF files and the new PDF import that came with version 12.2 is accepting a lot more PDF's than before but deletes the newlines the mark paragraphs. Are there any known options to not delete the additional newlines?

An easy example is created below.

teststring = "sentence1\nsentence2\n\nsentence3\n\n\nsentence4" 
(*Create a string with additional newlines*)
Export["newlinepdf.pdf", teststring] (*export to PDF*)
Import["newlinepdf.pdf", "Plaintext"] (*Import again and notice that the additional newlines are missing. This behaviour is consistent with all PDF's we tried*)
Import["newlinepdf.pdf", "PlaintextLegacy"] (*The leagcy undocumented option works (but doubles the newlines)for this example but fails with other PDF's we tried (errors out)*)

the test string prints out as

sentence1 sentence2

sentence3

sentence4

The Import gives

sentence1 sentence2 sentence3 sentence4

I'm using Windows 10 with MM12.2 PDF with MM 12.2 import does not include the newlines anymore. This is a very annoying issue since we would like to extract paragraphs which is now not possible. We tried other PDF import methods: PDF2TEXT which successfully keeps the additional newlines when importing the .txt file as TXT. Export using Acrobat reader with "Save as text file". When importing the file as a text file the additional newlines are present.

We need to import thousands of PDF files and the new PDF import that came with version 12.2 is accepting a lot more PDF's than before but deletes the newlines the mark paragraphs. In fact TextCases relies on the "return/newlines" code to detect paragraphs (see:https://reference.wolfram.com/language/ref/textcontent/Paragraph.html) so combined with the new PDF importer doesn't really makes it useful.

Are there any known options to not delete the additional newlines?

An easy example is created below.

teststring = "sentence 1\nsentence 2\n\nsentence 3\n\n\nsentence 4" 
(*Create a string with additional newlines*)
Export["newlinepdf.pdf", teststring] (*export to PDF*)
wrongstring=Import["newlinepdf.pdf", "Plaintext"] (*Import again and notice that the additional newlines are missing. This behaviour is consistent with all PDF's we tried*)
Import["newlinepdf.pdf", "PlaintextLegacy"] (*The leagcy undocumented option works (but doubles the newlines)for this example but fails with other PDF's we tried (errors out)*) 

Subscript[#, ToString@First@ToCharacterCode[#]] & /@ (teststring // Characters)

the teststring with charactercodes looks like this enter image description here

Subscript[#, ToString@First@ToCharacterCode[#]] & /@ (wrongstr // Characters)

The imported version with "Plaintext" option

enter image description here

Source Link
Lou
  • 4.1k
  • 23
  • 28

Importing PDF skips newlines

PDF with MM 12.2 import does not include the newlines anymore. This is a very annoying issue since we would like to extract paragraphs which is now not possible. We tried other PDF import methods: PDF2TEXT which successfully keeps the additional newlines when importing the .txt file as TXT. Export using Acrobat reader with "Save as text file". When importing the file as a text file the additional newlines are present.

We need to import thousands of PDF files and the new PDF import that came with version 12.2 is accepting a lot more PDF's than before but deletes the newlines the mark paragraphs. Are there any known options to not delete the additional newlines?

An easy example is created below.

teststring = "sentence1\nsentence2\n\nsentence3\n\n\nsentence4" 
(*Create a string with additional newlines*)
Export["newlinepdf.pdf", teststring] (*export to PDF*)
Import["newlinepdf.pdf", "Plaintext"] (*Import again and notice that the additional newlines are missing. This behaviour is consistent with all PDF's we tried*)
Import["newlinepdf.pdf", "PlaintextLegacy"] (*The leagcy undocumented option works (but doubles the newlines)for this example but fails with other PDF's we tried (errors out)*)

the test string prints out as

sentence1 sentence2

sentence3

sentence4

The Import gives

sentence1 sentence2 sentence3 sentence4