Ghostscript prints blank pages - windows

I'm trying to print PDF file to windows printers using ghostscript library.
This is my command:
gswin32c.exe -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=mswinpr2 -sOutputFile="\\printserver\myprinter" "C:\myfile.pdf"
This command works, I tried to print in a virtual printer (Windows PDF Printer) and it produces valid PDF.
I have some problem with a real printer using Toshiba Universal Printer Driver 2, all pages are printed completely blank (but the number of pages is right). I tried to change printer to another manufacturer and it works, so I suppose that the problem is connected to ghostscript and this particular Toshiba driver.
I tried to update this driver, I also tried to change client and I found that I have this problem only for some clients.
I tried to output some debug data with this command
gswin32c.exe -dPrinted -dDEBUG -dNumCopies=1 -sDEVICE=mswinpr2 -sOutputFile="\\printserver\myprinter" "C:\myfile.pdf"
I got this output:
START 0 1434368 139387 1309984 27572 true 582 3 <0>
GPL Ghostscript 9.23 (2018-03-21)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
END PROCS 2 1474576 176704 1330088 33388 true 705 3 <0>
END FONTDIR/ENCS 3 1514784 205041 1330088 35868 true 715 3 <0>
END DEVS 4 1532360 234258 1330088 35868 true 719 3 <0>
END STATD 5 1552464 247718 1330088 38748 true 724 3 <0>
END GS_FONTS 7 1622708 312812 1330088 38748 true 773 3 <0>
END BASIC COLOR 7 1622708 319016 1330088 38748 true 793 3 <0>
END IMAGE 8 1642812 330142 1330088 38748 true 798 3 <0>
BEGIN RESOURCES 21 2396164 1036997 1434800 144156 true 821 4 <0>
END CATEGORY 22 2396164 1040920 1434800 144444 true 822 5 <0>
END GENERIC 23 2426200 1063516 1434800 144444 true 824 4 <0>
END FIXED 24 2446304 1080587 1434800 144444 true 824 4 <0>
END MISC 25 2446304 1092183 1434800 144444 true 824 4 <0>
END ENCODING 26 2506616 1151689 1434800 148074 true 824 4 <0>
Extend MacRomanEncodingForTrueType for TrueType: insert /integral # 186
Extend MacRomanEncodingForTrueType for TrueType: cannot insert /Euro # 219 used for /currency
Extend MacRomanEncodingForTrueType for TrueType: insert /infinity # 176
Extend MacRomanEncodingForTrueType for TrueType: insert /notequal # 173
Extend MacRomanEncodingForTrueType for TrueType: insert /summation # 183
Extend MacRomanEncodingForTrueType for TrueType: insert /approxequal # 197
Extend MacRomanEncodingForTrueType for TrueType: insert /radical # 195
Extend MacRomanEncodingForTrueType for TrueType: insert /lozenge # 215
Extend MacRomanEncodingForTrueType for TrueType: insert /Omega # 189
Extend MacRomanEncodingForTrueType for TrueType: insert /pi # 185
Extend MacRomanEncodingForTrueType for TrueType: insert /product # 184
Extend MacRomanEncodingForTrueType for TrueType: insert /partialdiff # 182
Extend MacRomanEncodingForTrueType for TrueType: insert /greaterequal # 179
Extend MacRomanEncodingForTrueType for TrueType: insert /Delta # 198
Extend MacRomanEncodingForTrueType for TrueType: insert /apple # 240
Extend MacRomanEncodingForTrueType for TrueType: insert /lessequal # 178
END INITFILES 48 3724620 2302857 1434800 151334 true 1190 4 <0>
C:\Program Files (x86)\gs\gs9.23\bin/Fontmap 48 3744724 2311483 1454904 156508 true 1191 4 <1>
C:\Program Files (x86)\gs\gs9.23\lib/Fontmap 49 3784932 2343795 1454904 156508 true 1191 4 <1>
C:\Program Files (x86)\gs\gs9.23\fonts/Fontmap 49 3805036 2357477 1454904 156508 true 1191 4 <1>
%rom%Resource/Init/Fontmap 50 3805036 2367803 1454904 156508 true 1191 4 <1>
%rom%lib/Fontmap 51 3825140 2385363 1454904 156508 true 1191 4 <1>
c:/gs/gs9.23/Resource/Init/Fontmap 51 3845244 2399033 1454904 156508 true 1191 4 <1>
c:/gs/gs9.23/lib/Fontmap 52 3865348 2412693 1454904 156508 true 1191 4 <1>
c:/gs/gs9.23/Resource/Font/Fontmap 53 3865348 2423027 1454904 156508 true 1191 4 <1>
c:/gs/fonts/Fontmap 53 3885452 2436682 1454904 156508 true 1191 4 <1>
END FONTS 54 3885452 2447087 1454904 156508 true 1191 4 <0>
END DEVICE 4993 6016476 4383653 1453392 154996 true 1195 4 <0>
END CONFIG 4993 6016476 4383923 1453392 154996 true 1195 4 <0>
END INIT 4994 6096892 4457845 1566792 276716 true 1210 4 <0>
END GLOBAL 4994 6096892 4461827 1566792 279032 false 1209 4 <0>
END GC 5001 3920836 2285101 1570160 272553 false 988 3 <0>
runEPS: Not DSC
<<
/Info 22 0 R
/Root 1 0 R
/Size 23 >>
<<
/Info 22 0 R
/Root 1 0 R
/Size 23 >>
%Resolving: [1 0]
<<
/Pages 2 0 R
/Type /Catalog >>
endobj
%Resolving: [2 0]
<<
/Count 1 /Kids [
3 0 R
]
/Type /Pages >>
endobj
%Resolving: [3 0]
<<
/Contents [
20 0 R
]
/CropBox [
0.0 0.0 595.32 841.920044 ]
/MediaBox [
0.0 0.0 595.32 841.920044 ]
/Parent 2 0 R
/Resources 21 0 R
/Rotate 0 /Type /Page >>
endobj
%Resolving: [1 0]
%Resolving: [2 0]
%Resolving: [1 0]
%Resolving: [1 0]
%Resolving: [1 0]
%Resolving: [1 0]
Checking.
-dict-
-dict-
-mark-
-dict-
false
Merging.
-dict-
-dict-
-mark-
-dict-
false
Selecting.
-dict-
-dict-
-dict-
-mark-
-dict-
false
Constructing.
-dict-
-dict-
-dict-
-dict-
-mark-
-dict-
false
Putting.
[595.32 841.92]
/.MediaSize
true
/DisablePageHandler
0
/%MediaDestination
null
/LeadingEdge
0
/%MediaSource
-mark-
true
-dict-
-device-
-dict-
-dict-
-dict-
-dict-
-mark-
-dict-
false
Result of putting.
false
-device-
-dict-
-dict-
-dict-
-dict-
-mark-
-dict-
false
Installing.
false
-device-
-dict-
-dict-
-dict-
-dict-
-mark-
-dict-
false
Finishing.
-dict-
-dict-
-dict-
-dict-
-mark-
-dict-
false
%Resolving: [1 0]
%Resolving: [2 0]
Processing pages 1 through 1.
Page 1
%Resolving: [1 0]
%Resolving: [2 0]
%Resolving: [3 0]
%Resolving: [3 0]
%Resolving: [3 0]
%Resolving: [3 0]
%Resolving: [3 0]
%Resolving: [21 0]
<<
/Font <<
/F1 11 0 R
/F2 19 0 R
>>
>>
endobj
%Resolving: [21 0]
%Resolving: [21 0]
%Resolving: [2 0]
Checking.
-dict-
-dict-
-mark-
-dict-
false
-dict-
Merging.
-dict-
-dict-
-mark-
-dict-
false
-dict-
Selecting.
-dict-
-dict-
-dict-
-mark-
-dict-
false
-dict-
Constructing.
-dict-
-dict-
-dict-
-dict-
-mark-
-dict-
false
-dict-
Putting.
[595.32 841.92]
/.MediaSize
false
/PageUsesTransparency
0
/%MediaDestination
null
/LeadingEdge
0
/%MediaSource
-mark-
true
-dict-
-device-
-dict-
-dict-
-dict-
-dict-
-mark-
-dict-
false
-dict-
Result of putting.
false
-device-
-dict-
-dict-
-dict-
-dict-
-mark-
-dict-
false
-dict-
Installing.
false
-device-
-dict-
-dict-
-dict-
-dict-
-mark-
-dict-
false
-dict-
Finishing.
-dict-
-dict-
-dict-
-dict-
-mark-
-dict-
false
-dict-
before exec 5014 3907700 2337535 1944912 621210 false 988 7 <1>
%Resolving: [21 0]
%Resolving: [21 0]
%Resolving: [21 0]
%Resolving: [20 0]
<<
/Filter /FlateDecode /Length 205 >>
stream
%FilePosition: 214718
endobj
0.75 0.0 0.0 -0.75 0.0 841.920044 cm
q
1.0 1.0 1.0 rg
120.0 96.0 m
673.76 96.0 l
673.76 130.08 l
120.0 130.08 l
h
f
Q
q
0.0 0.0 0.0 rg
BT
0 Tr
/F1 14.7206 Tf
%Resolving: [21 0]
%Resolving: [11 0]
<<
/BaseFont /CIDFont+F1 /DescendantFonts [
<<
/BaseFont /CIDFont+F1 /CIDSystemInfo <<
/Ordering 4 0 R
/Registry 5 0 R
/Supplement 0 >>
/CIDToGIDMap /Identity /FontDescriptor <<
/Ascent 952 /CapHeight 631 /Descent -268 /Flags 6 /FontBBox 6 0 R
/FontFile2 8 0 R
/FontName /CIDFont+F1 /ItalicAngle 0 /StemV 7 0 R
/Type /FontDescriptor >>
/Subtype /CIDFontType2 /Type /Font /W 9 0 R
>>
]
/Encoding /Identity-H /Subtype /Type0 /ToUnicode 10 0 R
/Type /Font >>
endobj
runEPS: Not DSC
rewriting TempMapsNotDef
...FINISHED...
*** code space ranges ***
0
[(\000\000) (\377\377)]
*** defined charmap ***
2
[[]]
%Resolving: [4 0]
(Identity) endobj
%Resolving: [5 0]
(Adobe) endobj
%Resolving: [8 0]
<<
/Filter /FlateDecode /Length 142545 /Type /Stream >>
stream
%FilePosition: 130
endobj
DSIG 322052 7620
EBDT 65784 591
EBLC 65176 608
GDEF 129084 1558
GPOS 130644 191408
GSUB 66472 62610
OS/2 488 96
cmap 17956 700
cvt 31480 1468
fpgm 18656 3371
gasp 65160 16
glyf 32948 6652
head 364 54
hhea 420 36
hmtx 584 17372
kern 52492 66
loca 39600 12890
maxp 456 32
meta 66376 96
name 52560 12565
post 65128 32
prep 22028 9451
findname: 6 = (Calibri)
findname: 0 = (\251 2017 Microsoft Corporation. All Rights Reserved.\rHebrew OpenType Layout logic copyright \251 2003 & 2007, Ralph Hancock & John Hudson. This layout logic for Biblical Hebrew is open source software unde...)
findname: 1 = (Calibri)
findname: 4 = (Calibri)
findname: 5 = (Version 6.20)
head 236 54
hhea 290 36
maxp 326 32
OS/2 358 96
hmtx 454 17372
cmap 17826 700
fpgm 18526 3371
prep 21898 9451
cvt 31350 1468
glyf 32818 6652
loca 39470 12890
name 52360 12565
post 64926 32
GSUB 64958 62610
[236 54 36 32 96 17372 700 3372 9452 1468 6652 12890 12566 32 62610]
/FontMatrix
[1.0 0.0 0.0 1.0 0.0 0.0]
/FontBBox
[-0.502929688 -0.3125 1.24023438 1.02636719]
/FontName
(Calibri)
/FontInfo
-dict-
/XUID
[107 42 -2147483647]
FAPIhook CIDFont+F1
Trying to render the font Font CIDFont+F1 with FAPI...
Font CIDFont+F1 is being rendered with FAPI=FreeType
%Resolving: [9 0]
[
286 286 497 400 400 391 410 410 334 ]
endobj
FAPIhook CIDFont+F1
Font CIDFont+F1 is mapped to FAPI=FreeType
1 0 0.0 -1 120.0 110.08 Tm
[
(\001\232) -6.0 (\001\036) -0.558594 (\001\220) -0.113281 (\001\232) -0.960938 ]
TJ
ET
Q
q
0.0 0.0 0.0 rg
BT
0 Tr
/F2 14.7206 Tf
%Resolving: [21 0]
%Resolving: [19 0]
<<
/BaseFont /CIDFont+F2 /DescendantFonts [
<<
/BaseFont /CIDFont+F2 /CIDSystemInfo <<
/Ordering 12 0 R
/Registry 13 0 R
/Supplement 0 >>
/CIDToGIDMap /Identity /FontDescriptor <<
/Ascent 1079 /CapHeight 700 /Descent -250 /Flags 6 /FontBBox 14 0 R
/FontFile2 16 0 R
/FontName /CIDFont+F2 /ItalicAngle 0 /StemV 15 0 R
/Type /FontDescriptor >>
/Subtype /CIDFontType2 /Type /Font /W 17 0 R
>>
]
/Encoding /Identity-H /Subtype /Type0 /ToUnicode 18 0 R
/Type /Font >>
endobj
%Resolving: [12 0]
(Identity) endobj
%Resolving: [13 0]
(Adobe) endobj
%Resolving: [16 0]
<<
/Filter /FlateDecode /Length 70879 /Type /Stream >>
stream
%FilePosition: 143287
endobj
DSIG 140604 7624
GDEF 148228 808
GPOS 149036 80254
GSUB 229292 34382
LTSH 19784 5260
MERG 263804 12
OS/2 520 96
VDMX 25044 1504
cmap 115976 100
cvt 120840 2594
fpgm 116076 2652
gasp 140588 16
glyf 123436 1980
hdmx 26548 89428
head 396 54
hhea 452 36
hmtx 616 19166
kern 135932 30
loca 125416 10514
maxp 488 32
meta 263676 128
name 135964 4592
post 140556 32
prep 118728 2112
findname: 6 = (SegoeUI)
findname: 0 = (\251 2016 Microsoft Corporation. All Rights Reserved. )
findname: 1 = (Segoe UI)
findname: 4 = (Segoe UI)
findname: 5 = (Version 5.55)
head 236 54
hhea 290 36
maxp 326 32
OS/2 358 96
hmtx 454 19166
cmap 19620 100
fpgm 19720 2652
prep 22372 2112
cvt 24484 2594
glyf 27078 1980
loca 29058 10514
name 39572 4592
post 44164 32
GSUB 44196 34382
[236 54 36 32 96 19166 100 2652 2112 2594 1980 10514 4592 32 34382]
/FontMatrix
[1.0 0.0 0.0 1.0 0.0 0.0]
/FontBBox
[-0.572753906 -0.411132813 1.99902344 1.29833984]
/FontName
(SegoeUI)
/FontInfo
-dict-
/XUID
[107 42 -2147483646]
FAPIhook CIDFont+F2
Trying to render the font Font CIDFont+F2 with FAPI...
Font CIDFont+F2 is being rendered with FAPI=FreeType
%Resolving: [17 0]
[
20 20 539 ]
endobj
FAPIhook CIDFont+F2
Font CIDFont+F2 is mapped to FAPI=FreeType
1 0 0.0 -1 392.8 1022.72 Tm
[
(\000\024) -0.0625 ]
TJ
ET
Q
%Resolving: [21 0]
>>showpage, press <return> to continue<<
I had to truncate some data becase it is very long. I cannot understand this output and maybe it is not useful.
This test was made with a very simple PDF: just a "TEST" text wrote in MS Word. I tried to change PDF file but the problem is the same for all files.
What can I try to solve this problem?

The PDFDEBUG output is not useful. It would have been more useful to have given the back channel without setting PDFDEBUG.
I notice you say you 'have this problem only for some clients', which makes me think you may be using Ghostscript other than in accordance with the terms of the AGPL, you should review that before going further.
FWIW I doubt the problem is Ghostscript. All the mswinpr2 device does is render to a bitmap, draw that on the printer device context, and tell it to send itself to the printer. The simple way to tell is (on the machine with the problem) to simply have Ghostscript display the content of the test PDF file (-sDEVICE=display, or just omit it altogether). If that works, then its not Ghostscript, its something in the print pipeline.
The mswinpr2 device is very elderly, and the Windows print path has changed significantly since it was written. It may be that it simply doesn't work on Windows 10, or on some flavours of Windows 10, or some quirk of certain printer drivers on later versions of Windows doesn't work as expected.
Given the number of people I know for a fact are using the device, I'm confident that your problem is not a Ghostscript problem, as is also evident from the fact that you can get it to work on other machines.

Related

How to convert a cairo-pdf to eps without converting fonts to outlines

We use cairo to write pdf-files. The results are great, the files are editable so we can extract text via copy & paste or even open and edit the files in Adobe Illustrator and Inkscape to change the font properties.
But as soon as we convert the PDF to EPS all fonts are converted to outlines.
My favourite tools are pdftops and gs and this is the way I tried it:
gs -sDEVICE=eps2write -dLanguageLevel=3 -dEmbedAllFonts=true -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.eps input.pdf
and
pdftops -eps -level3 input.pdf output.eps
In addition I tried ps2eps, ps2epsi, epspdf and Inkscape via command line, but the result was always the same and all fonts are converted to outlines.
We are using the Dejavu-fonts and the font embedding seems to be OK:
$ pdffonts input.pdf
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
JTFVDF+DejaVuSans-Bold TrueType WinAnsi yes yes yes 5 0
BTWYHK+DejaVuSansCondensed-Bold TrueType WinAnsi yes yes yes 6 0
VIBPBS+DejaVuSans-Oblique TrueType WinAnsi yes yes yes 7 0
TKGUZX+DejaVuSansCondensed TrueType WinAnsi yes yes yes 8 0
Any idea how to produce EPS-files with editable Fonts?
Here is my file: https://www.dropbox.com/s/11afckra7i8trdq/input.pdf?dl=0
Ghostscript's eps2write device doesn't convert fonts to outlines. BTW how do you know the fonts are being converted to outlines ?
I'll grab the example file you supplied (kudos! a load of people don't do that) and report back shortly, I can think of 2 possibilities offhand:
The file contains transparency. Cairo has something of a habit of creating PDF files which contain transparency operations that don't actually do anything (like setting alpha to 100%). You can't represent PDF transparency in PostScript, so the whole page gets rendered to an image.
The file is an image (or similar) with text on top in text rendering mode 3 (neither stroke nor fill). Although the actual text is invisible, Acrobat and other applications will often allow you to cut/paste it. However, PostScript doesn't have a mode for doing this, and since the text doesn't make any marks, it usually just gets dropped.
[Later]
Hmm, complex file. Decompressed this is > 11 MB....
Anyway, the page is in a transparency group:
9 0 obj
<<
/Type /Page
/Parent 1 0 R
/MediaBox [ 0 0 720 720 ]
/Contents 3 0 R
/Group <<
/Type /Group
/S /Transparency
/I true
/CS /DeviceRGB
>>
/Resources 2 0 R
>>
endobj
However it looks like Ghostscript decided the transparency could be dropped as the page is not a complete bitmap.
The eps file I get out does not have the fonts converted to outlines, it embeds complete fonts, and it uses them, eg:
8 0 obj
<</BaseFont/ENTCOM+DejaVuSansCondensed-Bold/FontDescriptor 9 0 R/Type/Font
/FirstChar 32/LastChar 220/Widths[
313 0 0 0 0 0 0 0 0 0 0 0 0 374 0 0
0 0 0 0 0 626 626 626 0 0 0 0 0 0 0 0
0 696 686 660 747 615 615 738 753 334 0 697 573 896 753 765
659 765 693 648 614 730 696 993 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 730]
/Encoding 20 0 R/Subtype/TrueType>>
endobj
%%EndResource
9 0 obj
<</Type/FontDescriptor/FontName/ENTCOM+DejaVuSansCondensed-Bold/FontBBox[-362 -176 964 927]/Flags 4
/Ascent 745
/CapHeight 745
/Descent -176
/ItalicAngle 0
/StemV 144
/MissingWidth 540
/FontFile2 17 0 R>>
endobj
%%EndResource
%%BeginResource: file (PDF FontFile obj_17)
17 0 obj
<</Filter/ASCII85Decode
/Length1 6088/Length 7019>>stream
!!*'"!"ApY!!<3t:K&o%z!!!e-!!!""#r5Xnz!!!\J!!!)-#s2r:5.NBR!!!#S!!!("AoMC">68U0
!!!*T!!!##B5Dj*z!!!DJ!!!86BOtU_%6ag,!!!gs!!!!WBP:sc%JC""!!!,V!!!!EBPhj9z!!!f0
.....
Lots of data omitted
.....
!!)s8!!<3$zzzzzzz!!*'"!!6K:Z*:FC?Oo9l!$;IHze&!X4ze&!X4peC[h%QOi,!!*'*zz~>
endstream
endobj
So that's a TrueType font, which is later used:
10 0 0 10 0 0 cm BT
/R8 12.96 Tf
1 0 0 1 262.795 318.916 Tm
[(N)1(E)1(US)0.998415(T)79.0063(ADT)1.00218]TJ
126.609 339.675 Td
[(F)1(IN)1.00218(DO)0.998415(R)1.00218(F)0.998415(F)1.00218]TJ
-338.998 -203.387 Td
[(W)1(O)1(L)166.005(T)1(M)1(E)1(R)1(S)1(H)1(A)29.9863(US)1(E)1(N)1]TJ
373.499 -12.6809 Td
[(M)0.998415(IT)-21.9915(T)0.998415(E)1.00218]TJ
ET
It could be you are using an old version, I used the current version, 9.21. Failing that the obvious question would be 'why do you think the fonts are outlines ?'

Laravel 4 DomPDF - PHP not Streaming Issues

I am using laravel 4 with DOMPDF to display an PDF. While i am clicking PDF it will display like below:
%PDF-1.3 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj << /Type /Pages /Kids [6 0 R ] /Count 1 /Resources << /ProcSet 4 0 R /Font << /F1 8 0 R /F2 9 0 R >> /XObject << /I1 10 0 R >> >> /MediaBox [0.000 0.000 841.890 595.280] >> endobj 4 0 obj [/PDF /Text /ImageC ] endobj 5 0 obj << /Creator (DOMPDF) /CreationDate (D:20160823103816+00'00') /ModDate (D:20160823103816+00'00') >> endobj 6 0 obj << /Type /Page /Parent 3 0 R /Contents 7 0 R >> endobj 7 0 obj << /Filter /FlateDecode /Length 2558 >> stream x��[�n7}�W�1����v$�me%�29+$A�ز��d9F� �~�~j�3�K��l�L`b�����u�{�~;B�����`�)�$�XR��=���Ο��;"X�k��/�N7�E1L�e����¡��~���������w�������<>��/�����}��|���4�,������<�������緟����O�O7'�������?��d���s�WJ�9����1;$�4����:[-PJ/x � �����z�bԇY,��,_8�]-..���*��r��b5��ju�y}y�n���=Z/oV� �����+�U?~��U�#�d���TH��zq}�������f��"!6L��߻�� $��J�\����\�/����ƺ�� 0t���U���7v|~�$��N���������p8�i��<�>4�¥�� ��D¨�-�����C(*�e��mqFbn+���db!��5R4n�w�,�C��-���hSN1������|��� ��b*m��1���[$�����3���)9����N��a�U�y��Փ��[ ���g��|���y �ID�p<��� n�w��[)LU펝� S��z6o�yg���-��{���0�k�I���S��[�������;���5��&��؈��3�E�Y�*o k�� �0�X��6��yg���a�%n;��bw�鼤�#>T#/�X����ް��M�1D��<�E�Y�*o([+z�Zr��>KoPc�yp�ܳ#U��4>�[�F$��`��$��x��j�%5��� �[�X�0�A�y{��;T���auo��Bnf���;T�m�"���ƧkE������3��y�wc�f������+ZJ��'��A+�E�Y�*w {�*=c&'��,�Aav���!��"�,P����+��t�5e���4��y�o�w_>y�c ��$w��#֧҆Ns�n�{h�}D�8�{m)XZVmV�2��c7�'�6ԥQIo�*&t%ͭ�D눒fu�N�衒���.EA4�0 ��HD�g�u=�\�X��ZDs��P4����n��L��g����` �t�����Q�^�����́{�E3�k|�w'u9���h�CxwRw.�L!G��Ļ����R����́w�E3»����L�yg�Z4�!�;�;��� 9j�&�Fl��S�ҝ��\ G����K�r��nz͑̑w�E2y$�8�N�&��,��g�Z$s�;����n�=S2�y��|#�x��x�$s��j�̇������r��M�;�\���Z�Jw&�\ G����K� �L2�s��n�gI��=�"���餐�J7�)�#�,P�d>�нҝy��9J��^2yK��f�{�t=�\��g�&%sT��i՝d. �y��)�U��N�?�V�`�X�������1%i|L ��U��'���2��ih9,a�rF����pCCww�v/7ѩ�N�W P��9#��W���bx:\wU��2Aе0�2,�544wk���D"�/���[2(�C����1ByK����PA��`�C��?��h�[2(/�����*ByK�=��U�eq񂥏t��K�%ByK��K ����y���%��j�'���FP�҇ a�$��>ByK�g����$��%��cxm�&���,}�09�መ\]�w#��dp~�-±I,?�F,oɰ�|�����2#KJ�"��T��8�vr��$��%��͆�3X2�~,1�B����zS�j`c�����^.�}����ޣ�ً���K��p8�9�܌��ߟ����COc�������oX��juw�ipA�Y5%`jqR���=��Xp���&�[�B��`el2��^nG?��YZ!s�����_���tU6��m�֍ n&OhgI���`�k;�)��˦ �Sm�4�쵇������*> endobj 9 0 obj << /Type /Font /Subtype /Type1 /Name /F2 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >> endobj 10 0 obj << /Type /XObject /Subtype /Image /Width 64 /Height 64 /Filter /FlateDecode /DecodeParms << /Predictor 15 /Colors 3 /Columns 64 /BitsPerComponent 8>> /ColorSpace /DeviceRGB /BitsPerComponent 8 /Length 929>> stream h�՚�n�#����T�R�#���.�"Z!�����P���\!W[M�.����]�,��*#ș��������3����6��n�O�M]�#����|֯/�����D4�I��LJ�pEQ�$UUM\UU�e�l6�O~C�8��|��DD��>�cD�>5��������k�~�gߴZ ���bQŤ4QY���g��$��"*�b�X�Z�ડ,����#'I�N��O b����nD?Q�睑��Q����j+��z�6Xfp�����{��3w##��k�!��<�<�TU�~�����r��R�y�{���`/1˲p9��k�8��~��slpW?��4ǽ��3VI܂�LY� �ӮY���"��|���#p�>9=,k[�;� u]ߝsl�M��%p����fE��^`\�%=��["�e^b�-�|CHcS[뺶��,��õ��O�n�K�Tv��󒾝��}a�5/��N �M���x�7 "�y\��� ��������L(Dt:��,��wQ�$�T����C���(���cs� �3����9�vƒ�R���}�6��XL�R�t:%Ib��!v�2��������M���#峷����1H�V_(��C�NS�����\sV�ՀS���a����i��~i`��b�c��0D�����N8�I��k}�Ӷ�����}����Y��Ŵ�ug|_�}��������>���M��L��b9/�z�k��Ͼ�ͼ�-����c��i����;B�{�#�֌�O������`�����*�BvΑ����k}���%�9kǪ���yi>������i�N�z���������f�a�O���`�ݎg�/��� endstream endobj xref 0 11 0000000000 65535 f 0000000008 00000 n 0000000073 00000 n 0000000119 00000 n 0000000310 00000 n 0000000347 00000 n 0000000461 00000 n 0000000524 00000 n 0000003155 00000 n 0000003262 00000 n 0000003374 00000 n trailer << /Size 11 /Root 1 0 R /Info 5 0 R >> startxref
How to solve this issues. Please Help Me. Thanks in advance
You can check how to convert data into pdf here. Try this code in to generate pdf. Dont forget to use dompdf library.

VB script InStr returning later instance of string

I have a script that is supposed to find the number of pages in a PDF document. In some cases, it is finding this incorrectly, and I'm looking at it and finding something puzzling: InStr isn't returning the first instance of my string, but one in the middle. Here is some code:
Set TempFile = fso.OpenTextFile(sFileName, 1)
lNumPages = 0
sLine = TempFile.ReadAll
Temp = InStr(sLine, "/Count ")
'Strip out the number of pages
lNumPages = CLng(Mid(sLine, Temp + 7, InStr(Temp + 1, sLine, "/") - Temp - 7))
Using a text editor (Textpad in this case) I can see the following in the file itself when I search for "/Count ":
515 0 obj
<<
/Count 13
/Kids [ 516 0 R 520 0 R 525 0 R 528 0 R
532 0 R 535 0 R 539 0 R ]
/Type /Pages
>>
endobj
516 0 obj
<<
/Count 2
/Kids [ 517 0 R ]
/Parent 515 0 R
/Type /Pages
>>
endobj
517 0 obj
<<
/Count 2
/Kids [ 518 0 R 519 0 R ]
/Parent 516 0 R
/Type /Pages
>>
endobj
down to
522 0 obj
<<
/Count 1
/Kids [ 53 0 R ]
/Parent 521 0 R
/Type /Pages
>>
endobj
523 0 obj
<<
/Count 1
/Kids [ 97 0 R ]
/Parent 521 0 R
/Type /Pages
>>
endobj
524 0 obj
<<
/Count 1
/Kids [ 136 0 R ]
/Parent 521 0 R
/Type /Pages
>>
endobj
525 0 obj
<<
/Count 1
/Kids [ 526 0 R ]
/Parent 515 0 R
/Type /Pages
>>
endobj
and more. The issue is that the Temp = InStr(sLine, "/Count ") line sets Temp to the position for /Count following the 522 object, instead of the first instance, the 515 object, which all text editors find.
I even did a hex comparison, and find them all to be the same, with the following characters: 43 6F 75 6E 74 20 31 33
What could possibly be causing InStr to locate a string that is neither first nor last?
The file is about 532k, but the first character found with InStr is at position 532,584, so not really close to 524,288, either, if it would make any difference.

PDF inline Image does not work

I defined an image within a pdf stream. It works correctly an shows me a red 4 pixel palette:
%PDF-1.7
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
/PageMode /UseNone
>>
endobj
2 0 obj
<<
/Type /Pages
/Count 1
/Kids [3 0 R]
>>
endobj
3 0 obj
<<
/Type /Page
/Parent 2 0 R
/MediaBox [0 0 50 20]
/Contents 4 0 R
/Resources
<<
/XObject << /Im1 5 0 R >>
>>
>>
endobj
4 0 obj
<<
/Length 38
>>
stream
40 0 0 10 5 5 cm
/Im1 Do
endstream
endobj
5 0 obj
<<
/Type /XObject
/Subtype /Image
/Width 4
/Height 1
/ColorSpace /DeviceRGB
/BitsPerComponent 2
/Filter /ASCIIHexDecode
/Length 10
>>
stream
01 08 30
endstream
endobj
xref
0 6
0000000000 65535 f
0000000009 00000 n
0000000090 00000 n
0000000155 00000 n
0000000311 00000 n
0000000400 00000 n
trailer
<<
/Size 6
/Root 1 0 R
>>
startxref
720
%%EOF
But when I try to show the same image as an inline image, there is only a blank page:
...
...same as above...
...
3 0 obj
<<
/Type /Page
/Parent 2 0 R
/MediaBox [0 0 50 20]
/Contents 4 0 R
>>
endobj
4 0 obj
<<
/Length 92
>>
stream
40 0 0 10 5 5 cm
BI
/W 4
/H 1
/CS /RGB
/BPC 2
/F /AHx
ID
01 08 30
EI
endstream
endobj
...
When I use no abbreviations for the image properties, there is already a blank page.
Does anyone has an idea what could be the problem?
Thank you for any hint and help!
Okay, the last two days I read the specification again and again. But it was worthwhile.
There were two mistakes. Only the correction of both of them gave me my wanted result...
First of all I did not end the ASCIIHexDecodeFilter portion between ID and ED. The specification says: "A right angle bracket character (>) indicates EOD." If there is a full stream filtered with ASCIIHexDecodeFilter, the Adobe Reader knows about the end of the stream by reading the /Length attribute. But as part of the stream itself it needs the > character.
The second thing is that my page object (3 0 obj) requires a /Resources attribute mandatory. It may be empty (/Resources << >>) but it may not be missing.
Thanks for everyone who tried to answer or help!!
Here the correct working inline image PDF file stream:
%PDF-1.7
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
/PageMode /UseNone
>>
endobj
2 0 obj
<<
/Type /Pages
/Count 1
/Kids [3 0 R]
>>
endobj
3 0 obj
<<
/Type /Page
/Parent 2 0 R
/MediaBox [0 0 50 20]
/Contents 4 0 R
/Resources << >>
>>
endobj
4 0 obj
<<
/Length 90
>>
stream
q
40 0 0 10 5 5 cm
BI
/W 4
/H 1
/CS/RGB
/BPC 2
/F /AHx
ID
01 08 30 >
EI
Q
endstream
endobj
xref
0 5
0000000000 65535 f
0000000009 00000 n
0000000090 00000 n
0000000155 00000 n
0000000277 00000 n
trailer
<<
/Size 5
/Root 1 0 R
>>
startxref
418
%%EOF

GhostScript issue with extracting text, and -dProvideUnicode usage

I use GS with DjVu driver, as in this example:
gs %gs_args% -dProvideUnicode -dExtractText -sDEVICE=djvusep -o out.sep in.ps
and noticed issue, that with some files text is not correctly extracted (I get question marks in clipboard on copying text from generated file).
I thought it's some issue with encoding, and removed -dProvideUnicode switch, but then text is not extracted at all, and I assume that -dExtractText flag, specific only to this driver, needs it to function properly.
Trying to run single page PDF file (that generated in.ps through ps2write device), with ps2ascii gives also no text. But other tools like pdfminer, xpdf, extract correct text. Also PDF viewers like SumatraPDF that uses mupdf, or Acrobat, extract the text as expected.
Does anyone maybe knows something about these undocumented switches, and what could be the problem here?
Update: This only happens if I go through ps2write route. If instead I use PDF directly there is no issue.
Here is encoding info from the PDF file:
c:\temp>pdf-parser -s encoding sample.pdf
obj 11 0
Type: /Font
Referencing: 12 0 R, 20 0 R
<<
/BaseFont /XQKNMY+TT14112O00
/FontDescriptor 12 0 R
/Type /Font
/FirstChar 32
/LastChar 144
/Widths [
253 0 0 0 0 0 0 0 293 293 0 0 220 313 220 0
0 467 467 0 0 0 467 0 467 467 0 0 0 0 0 0
0 680 0 0 0 653 0 773 760 0 0 740 0 833 0 0
0 0 0 480 613 0 680 0 0 0 0 0 0 0 0 0
0 407 513 414 500 414 320 447 513 227 0 467 227 773 513 513
513 0 333 367 293 487 467 667 460 414 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
220]
/Encoding 20 0 R
/Subtype /Type1
>>
obj 20 0
Type: /Encoding
Referencing:
<<
/Type /Encoding
/BaseEncoding /WinAnsiEncoding
/Differences [
144/quoteright]
>>
This isn't really a Ghostscript question. The djvu device is decidedly non-standard in a Ghostscript build. I can't tell you anything about the switches, because they are specific to the DejaVu device.
If all you want to do is extract the text from a file you could use the txtwrite device (with recent versions of Ghostscript).
If you use a PDF file then a ToUnicode CMap may be present in the file and can be used to get Unicode information about the text. PostScript does not contain ToUnicode CMaps and so the Unicode information is NOT available from the PostScript file. I would imagine this is why the ps2write output can't have text extracted from it by the device.

Resources