Forum moved here!

Home / How Use SumatraPDF in my C# Application?

ligteltelecom

I want open and how PDF file inside my apllication using SumatraPDF. I dont want change, create, print PDF. Just open PDF with Password.

Can Someone help me?

GitHubRulesOK

SumatraPDF is a Standalone AGPL licensed viewer so you simply shell out to run SumatraPDF.exe (same as any other window.app.)

There is no backend support for passwords other than storing user provided password to open or using any hashes that you include/provide. Thus why bother using passwords ? since they needs be accessible.to any user.
" A document open password in Adobe Acrobat, other PDF programs may refer to this password as the PDF user password", because you have to hand over full rights to VIEW and remove password or copy etc. by giving the password to the user. otherwise they need to use brute force.

As a fast viewer SumatraPDF has to slow down as required to decrypt and decompress the PDF content onto the screen, If you want to annoy readers by using slow decompression and heavy encryption there are many much slower PDF products…

IF the reason is to ensure a client user can OPEN a secured account detail then simply use their account password for their pdfs until their account password changes. Then they simply need to store the ONE password for all their communications.

For that scenario you can tell them to use notepad to add.a whitespace separated list of passwords to try when opening a password protected document (passwords containing spaces must be quoted) (introduced in version 2.4)
DefaultPasswords = "MyLigTel Pa55w0Rd"

ligteltelecom

PDF files have a default password. I just want to open the PDF inside my application (showing in a FORM or Panel).

Can you help me?

ligteltelecom

my code below:
ProcessStartInfo psi = new ProcessStartInfo(@“C:\test\SumatraPDF-dll.exe”);
psi.Arguments = @“c:\test\K130F_SVC_Manual_V1.0_160204.pdf”;
psi.WindowStyle = ProcessWindowStyle.Minimized;

        Process p = Process.Start(psi);
        //p.WindowStyle = ProcessWindowStyle.Minimized;
        p.WaitForInputIdle();
        Thread.Sleep(3000); //sleep for 3 seconds
        SetParent(p.MainWindowHandle, panel1.Handle);
        SetWindowLong(p.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
        MoveWindow(p.MainWindowHandle, 0, 0, panel1.Width, panel1.Height, true);
GitHubRulesOK

There is a key issue here primarily around AGPL licensing.
(I still fail to see any benefit about using passwords, since they must by definition be user accessible)
Under AGPL you may commercially shell SumatraPDF.exe, there is no intentional API since the core library is AGPL. Thus if embeding SumatraPDF your source code must be public including the password !

If you need a password to not be public you would need to use the commercial MuPDF library from Artifex.

ligteltelecom

This software use SumatraPDF (it use PDF.dll) and no public password and source code to public

dzkj16888

I want use Sumatra as it use.

GitHubRulesOK

I am removing your link as that pirated copy has a poor reputation

Execution Parents

Scanned Detections Type Name
2020-04-23 46 / 72 Win32 EXE 27.tmp
2020-09-05 36 / 67 Win32 EXE DZClient.exe
2020-07-06 52 / 73 Win32 EXE 932466e94a23e413db58d584902218e3.virus
(VirusTotal)
2020-07-19 58 / 72 Win32 EXE DZClient.exe
ligteltelecom

After compiled Sumatra. i have PDF.DLL in folder.
If i install COM Compontes and selected this DLL , IT shown OCx SmartPDF.

PDF.dll
How load PDF File using this COM Component?
public virtual sbyte OpenPDF(string docPath, int bufferAddr, int doclen, sbyte mod);

I tried this code below
axSmartPDF1.OpenPDF(@“c:\test\testepdf.pdf”, buffAddr, 0, sbyte.MaxValue);

GitHubRulesOK

This PDF.dll is not SumatraPDF it is one of many Chinese knock off’s (illegal clones). SumatraPDF was NP api not OCX, also SmartPDF was an open fork built for ReactOS

   "21 security vendors flagged DZKJ-1.0.0.## as malicious"

ligteltelecom

I dont understand.
How it create PDF.dll ?
I did open PDF.DLL note edit and get this below

  • [%s] SumatraPDF%s %s- %s[Changes detected; refreshing] %sThis document uses unsupported features (%s) and might not render properlyBookmarksFavoritestooltips_class32File %s not foundError loading %sPage:%s %d / %d%s %s (%d / %d)inptmm%s x %s %sCursor position:%s %sSelection:%s - %s
GitHubRulesOK

Sorry for delay there was a forum server hiccup (now fixed)

You are correct the author of that DLL copied all the Open Source code and wrapped it in their software.

Since the SumatraPDF exe core is AGPL Open Source you can ask them to openly publish their wrapping code, or disassemble and publish it on their behalf?.

Since I dont wish to be infected by their malware I did not use their server to download the pay to view copies of pdf, but did not see any suggestion they are password protected. No password was needed for the PDFs I was served. The password their software first raises is for pay to view accounts access.

Here is a more “legal” open source use of the released sumatrapdf.exe versions 3.1.2 and 3.2 without a dll however their public domain “Harbour” open source wrapper can be difficult to find.

ligteltelecom

I want use this PDF.DLL but no sucess.