Generating .pdf files with batch?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
miskox
Posts: 630
Joined: 28 Jun 2010 03:46

Re: Generating .pdf files with batch?

#31 Post by miskox » 21 Dec 2017 04:05

Great, Steffen!

Thanks.

Saso

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Generating .pdf files with batch?

#32 Post by aGerman » 21 Dec 2017 10:55

Thanks for your feedback, Saso!

For those of you guys who want to see the uncompressed human-readable code I'd like to add it to this thread, too.
Do not use it! It's ~25% slower for lines that contain tabs and still ~10% slower for files that don't contain tabs. ( rather use viewtopic.php?f=3&t=8289&start=15#p55139 )

Steffen
Attachments
txt2pdf_long.zip
(2.41 KiB) Downloaded 594 times

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Generating .pdf files with batch?

#33 Post by aGerman » 23 Oct 2022 04:28

einstein1969 posted a version which is both readable and fast. Thanks!
viewtopic.php?p=67779#p67779

Steffen
Attachments
txt2pdf_einstein.zip
(2.44 KiB) Downloaded 331 times

miskox
Posts: 630
Joined: 28 Jun 2010 03:46

Re: Generating .pdf files with batch?

#34 Post by miskox » 23 Oct 2022 11:04

Wow! Great! Thanks to you both! Works great. Of course there is still a problem with our national characters. Steffen: do your umlaut letters for example get enconded successfully?

Saso

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Generating .pdf files with batch?

#35 Post by aGerman » 23 Oct 2022 11:35

I've been never able to get around the limitation of supporting Windows-1252 only. That's kind of the default for PDF. I don't know how to get Unicode support, sorry.

Steffen

miskox
Posts: 630
Joined: 28 Jun 2010 03:46

Re: Generating .pdf files with batch?

#36 Post by miskox » 23 Oct 2022 11:59

Yes, PDF specification says that special characters should be embedded (fonts I think). Not easy to do.

Anyway. Einstein's solution is great, too.

Thanks.
Saso

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Generating .pdf files with batch?

#37 Post by einstein1969 » 23 Oct 2022 12:27

This version on my system passed from 43sec to 11sec (4X)

I have insert the subs inline and changed the strlen into macro faster version
Attachments
test.zip
(41.59 KiB) Downloaded 369 times

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Generating .pdf files with batch?

#38 Post by einstein1969 » 23 Oct 2022 12:50

there is a very strange thing, you can check that you have more experience.

if I transform the tab_iter into this:

Code: Select all

set i=0
For /L %%. in (1,1,1250) do (
  if !i! lss !len! (
    set /a "nxt=!i!+1"
    for %%I in (!i!) do (
	if "!ln:~%%I,1!"=="%tab%" (
      		set /a "d=0-(%%I %% tabWidth)+tabWidth, e=nxt, nxt+=d-1, len+=d-1"
      		for /f "tokens=1,2" %%D in ("!d! !e!") do set "ln=!ln:~0,%%I!!spcs:~0,%%D!!ln:~%%E!"
        )
    )
    set /a i=nxt
  )
)
and I insert it in the block with the set / P (I avoid the CALL) the execution time of the batch doubles! I do not understand why'....

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Generating .pdf files with batch?

#39 Post by einstein1969 » 24 Oct 2022 03:24

last version. I have inline strlen. Last code 8sec on my laptop

Code: Select all

short code
Elapsed 76 sec.
long code
Elapsed 96 sec.
einstein code
Elapsed 42 sec.
einstein code 2
Elapsed 15 sec.
long code (einstein latest)
Elapsed 15 sec.
long code (einstein latest 2)
Elapsed 9 sec.
long code (einstein latest 3)
Elapsed 8 sec.
Premere un tasto per continuare . . .
Attachments
2pdf.zip
(93.91 KiB) Downloaded 376 times

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Generating .pdf files with batch?

#40 Post by einstein1969 » 24 Oct 2022 03:29

einstein1969 wrote:
23 Oct 2022 12:50
there is a very strange thing, you can check that you have more experience.

if I transform the tab_iter into this:

Code: Select all

set i=0
For /L %%. in (1,1,1250) do (
  if !i! lss !len! (
    set /a "nxt=!i!+1"
    for %%I in (!i!) do (
	if "!ln:~%%I,1!"=="%tab%" (
      		set /a "d=0-(%%I %% tabWidth)+tabWidth, e=nxt, nxt+=d-1, len+=d-1"
      		for /f "tokens=1,2" %%D in ("!d! !e!") do set "ln=!ln:~0,%%I!!spcs:~0,%%D!!ln:~%%E!"
        )
    )
    set /a i=nxt
  )
)
and I insert it in the block with the set / P (I avoid the CALL) the execution time of the batch doubles! I do not understand why'....
I understand why: it is called thousands of times and actually did about 1000 * 1000 if useless

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Generating .pdf files with batch?

#41 Post by einstein1969 » 24 Oct 2022 03:45

there was a wrong version in the zip I corrected and redid the tests. last version 10X

Code: Select all

short code
Elapsed 83 sec.
long code
Elapsed 95 sec.
einstein code
Elapsed 44 sec.
einstein code 2
Elapsed 15 sec.
long code (einstein latest)
Elapsed 11 sec.
long code (einstein latest 2)
Elapsed 9 sec.
long code (einstein latest 3)
Elapsed 8 sec.
Attachments
2pdf.zip
(106.95 KiB) Downloaded 351 times

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Generating .pdf files with batch?

#42 Post by einstein1969 » 24 Oct 2022 07:53

I have made further progress.

I calculated the maximum expansion of the tabs and brought the tab_iter into the main loop. No more while..do / repeat..until loops
I have minimized the Sets and the calls to the strlen.
I have added comments

doubled the size of the txt, now it's 646KB.

Execution time dropped by 20% since last code. From 200 sec to 16 sec on my laptop. 13X

have a coffee during the tests ...

Code: Select all

short code
Elapsed 206.4 sec.
long code
Elapsed 222.9 sec.
einstein code
Elapsed 127.8 sec.

Code: Select all

einstein code 2
Elapsed 37.8 sec.
long code (einstein latest)
Elapsed 23.5 sec.
long code (einstein latest 2)
Elapsed 21.0 sec.
long code (einstein latest 3)
Elapsed 19.6 sec.
long code (einstein latest 4)
Elapsed 16.0 sec.
the fastest version is "txt2pdf_long5.bat"
Attachments
2pdf.zip
(175.04 KiB) Downloaded 354 times

miskox
Posts: 630
Joined: 28 Jun 2010 03:46

Re: Generating .pdf files with batch?

#43 Post by miskox » 26 Oct 2022 04:18

Thanks! Will check.

In the mean time I checked the .pdf reference again. I still don't have a solution to embed a font (only characters I need) to the .pdf. Maybe one day.

Saso

Post Reply