Pechkin icon indicating copy to clipboard operation
Pechkin copied to clipboard

Maximal image size

Open enKor opened this issue 12 years ago • 10 comments

Hi, is there a maximal filesize or resolution of used images? I have problem when I use images in full resolution (from a camera - about 6Mpx?). When I use this fullsize image, the PDF cannot be created. But when I use smaller images it works fine. IDNK if it depends on "kB" size or "px" resolution. Any tips? Thanx

enKor avatar Nov 09 '12 09:11 enKor

@enKor You can set image quality with .SetMaxImageDpi() and .SetImageQuality() options in GlobalConfig. You can enable local resources with .SetAllowLocalContent(true) in ObjectConfig.

Taken from a @gmanny answer to a similar post that may help here: https://github.com/gmanny/Pechkin/issues/7

Example of using Global config can be found here add in what you need from the above and test : http://stackoverflow.com/questions/13267838/pechkin-html-to-pdf-that-includes-a-link-to-a-png-from-an-ssl-url

bUKaneer avatar Nov 12 '12 21:11 bUKaneer

Hello, I tested the library with both http://yhub.ru/u/p/PIA16239.jpg and http://yhub.ru/u/p/PIA16239.png, these are 35 Megapixel images, the second one is 38 MB. It rendered them fine.

I used these (random) options for that:

SynchronizedPechkin sc = new SynchronizedPechkin(new GlobalConfig().SetMargins(new Margins(300, 100, 150, 100))
                .SetCopyCount(1)
                .SetLosslessCompression(true).SetOutlineGeneration(true).SetOutputDpi(1200).SetPaperOrientation(true)
                .SetPaperSize(PaperKind.Letter));

byte[] buf = sc.Convert(new ObjectConfig(), htmlText.Text);

gmanny avatar Nov 12 '12 21:11 gmanny

Could you please provide more details about the error you are getting?

gmanny avatar Nov 12 '12 21:11 gmanny

Also, you could try using images from URLs I've provided and check whether your code works with them.

gmanny avatar Nov 12 '12 21:11 gmanny

Discovered that the actual code was without any options. Just

IPechkin sc = new SimplePechkin(new GlobalConfig().SetPaperSize(PaperKind.Letter).SetPaperOrientation(true));

byte[] buf = sc.Convert(new ObjectConfig(), htmlText.Text);

gmanny avatar Nov 12 '12 22:11 gmanny

But when I try to apply it on http://www.prevlec.cz/db/ShowReport.aspx?code=repTiskProtokolu&id0=280284&usrlg=FiaL79o12 it do not work. I use this setup: SynchronizedPechkin sc = new SynchronizedPechkin(new GlobalConfig() .SetMargins(new Margins(10, 10, 10, 10)) .SetDocumentTitle("Report") .SetCopyCount(1) .SetImageQuality(100) .SetLosslessCompression(true) .SetMaxImageDpi(12000) .SetOutlineGeneration(true) .SetOutputDpi(300) .SetPaperOrientation(false) .SetPaperSize(PaperKind.A4));

and then:

byte[] buf = sc.Convert(new ObjectConfig().SetPrintBackground(true) .SetLoadImages(true) .SetAllowLocalContent(true) //.SetIntelligentShrinking(true) //.SetScreenMediaType(true) .SetZoomFactor(2.0) .SetCreateForms(false), new Uri(sUrl));

enKor avatar Nov 13 '12 09:11 enKor

it throws: Unhandled exception at 0x77e4bef7 in MyWinFormApp_PdfGenerator.exe: 0xE0434352: 0xe0434352.

enKor avatar Nov 13 '12 09:11 enKor

There's no Convert method that takes both ObjectConfig and Uri.

gmanny avatar Nov 13 '12 10:11 gmanny

I also haven't encounter the error, when I ran the code you've provided (with the new Uri(sUrl) substituted with just sUrl), everything went fine, even from multiple threads.

I think it has to do with the thread-safeness of the component. Are you testing in the isolated environment, or in production/web? I. e. does it happen in the program which has only that code?

gmanny avatar Nov 13 '12 10:11 gmanny

  1. It runs in console app. It is a small app of some SQL updates and when all updates are done, then creates the PDF
  2. I have created (small change) the overload for both ObjectConfig and Uri

enKor avatar Nov 13 '12 12:11 enKor