❔ List contains 600+ lines, the file that it writes to contains only 130, why?
I got a pdf with a few pages, alot of lines, anybody got and idea?
When i stop on debug, wordsInPage contains 600+ lines.
that's the entire code:
61 Replies
What is the type of wordsInPage
List<string>
How many lines are being print to the console?
130smth
If list contains 600 items there is no way a for loop would print just 130 items
but wordsInPage.count is 600+
can you share the pdf file?
yup thats what im having trouble undersanding
https://www.analog.com/media/en/technical-documentation/data-sheets/ad9361.pdf
big ass pdf, has way more then 130 lines
What nuget package are you using for PDFDocument
PigPdf
PdfPig 0.1.7
Reads text content from PDF documents and supports document creation. Apache 2.0 licensed.
alright let me run this. give me a sec
you should see the count on 693 I think
I'm getting count 693 yes
Thats odd aint it lol?
never seen such behavior
that doesn't have anything to do with the nuget, that's been extracted into a list of strings
seems like your buffer is having some problems
try
on it
@Henkypenky that gave me 20 more lines
aka 150+ , not the 693 i should be getting
wait
im getting 152 lines
weird
yup exactly
smth is so odd lol
very weird
try
and im writing those lines just to test if i see a certain value
it prob fucks up the loops after too
im guessing
unsure
back to 136 lol
@Orannis aint u some c# god? save us
okay try this
waiit that code not correc tXD
cant paste it in
we are using "using" instead of try/finally here yearh?
unsure what u mean?
136 lines
no change
and the week has barely started
fml
I've never seen this behavior
didnt know it can even happen
i have
final try
same result lol
136 lines
only your first methode gave me +20 lines, but even that not close to the full number heh
in my behavious i saw
last line was skipped
flush solved it
but this many lines is weird
skips about 550 lines
insane
can you do
I think i've figured it out
Console.WriteLine(wordsInPage.Count
gimme a sec
before the foreach
LOL
693
220
302
324
253
313
400
286
285
169
264
163
162
75
288
567
756
731
631
395
377
516
418
336
392
375
484
203
387
368
503
213
884
859
773
152
i think
thats page related now
did u add it inside the foreach
there are about 30 pages
no
outisde of it
its in the foreach of the pages
there are 30 pages in that pdf
so the 152 is working correctly
i dont think so
it stops at first page
on line 152
bro
here is the problem
not on the page that contains 152 lines
your for loops are strutured weird
let me explain
i think you are overwriting everything
start by dismantling your problem
do page 1
only
henky you're right
that's exactly what's happening here
snappp
makes sense!
im recreating the file
each time
last iteration is the 136 one prob
or 152
w/e
lol
i was sure it would be locked tho, or just add to it, not overwrite it
didnt know it behaves like this
good catch guys
you need to not "using" the streamwriter
so:
create the streamwriter
do the page foreach
do the lines foreach
then flush close and dispose the writer
Will do boss thanks! helped alot wouldnt have caught it for hours by myself probably
dw, glad we could help
bro
your wordsinpage count is off too
try this
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.